imhist() is not generating histogram image of image

6 次查看(过去 30 天)
i have an RGB image and i am trying to generate histogram from the intensity image of the RGB. but my code is not generating histogram. please let me know how to solve
Pic = 'violet.bmp';
s1 = imread(Pic);
I1 = rgb2gray(s1);
imhist(I1);
imshow(I1);
drawnow();
this code only generatig till rgb2gray(), it is not generating imhist() part.

采纳的回答

Image Analyst
Image Analyst 2013-2-20
imhist(), as you called it, will display the histogram only. It will not return the histogram bin values. However, you immediately cover it up with the image so that the histogram can no longer be shown. Try this:
baseFileName = 'violet.bmp';
fullFileName = fullfile(pwd, baseFileName);
if exist(fullFileName)
rgbImage = imread(fullFileName);
grayImage= rgb2gray(rgbImage);
[pixelCounts grayLevels] = imhist(grayImage, 256);
bar(grayLevels, pixelCounts);
xlim([0 255]);
uiwait(msgbox('Click OK to see the image'));
imshow(grayImage);
else
warningMessage = sprintf('Error: file not found\n%s', fullFileName);
uiwait(warndlg(warningMessage));
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by