MATLAB: How to find out the different intensity values that are used in the image and make out a list of them.Then find the freq. of occurence (probability) of each of intensity values in the image

histogramImage Processing Toolboxintensitypdf

How to find out the different intensity values that are used in the image and make out a list of them. Then find the freq. of occurrence (probability) of each of intensity values in the image?

Best Answer

grayImage = rgb2gray(YourImage);
[unique_vals, ~, idx] = unique(grayImage(:));
counts = accumarray(idx(:), 1);
probs = counts ./ sum(counts);
bar(unique_vals, probs);
Related Question