MATLAB: Compare the levels of gray

graphhistogramimageImage Processing Toolbox

Could you tell me how to compare the levels of gray between several photographs and show (increase)it on the graph ? By histogram ?

Best Answer

See this snippet
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(grayImage);
bar(grayLevels, pixelCount);
grid on;
title('Histogram of image', 'FontSize', 22);
xlim([0 255]); % or 65535 if image is uint16
% Compute and display mean
meanGrayLevel = mean2(grayImage);
message = sprintf('The mean gray level is %.2f', meanGrayLevel);
uiwait(helpdlg(message));