フィルターのクリア

imhist() is not generating histogram image of image

5 ビュー (過去 30 日間)
Sat m
Sat m 2013 年 2 月 20 日
コメント済み: Zahra Saman 2018 年 4 月 12 日
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
  2 件のコメント
Sat m
Sat m 2013 年 2 月 20 日
thank you. it is working now. thank you
Zahra Saman
Zahra Saman 2018 年 4 月 12 日
please help me is this problem

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by