필터 지우기
필터 지우기

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