Borrar filtros
Borrar filtros

imhist() is not generating histogram image of image

5 visualizaciones (últimos 30 días)
Sat m
Sat m el 20 de Feb. de 2013
Comentada: Zahra Saman el 12 de Abr. de 2018
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.

Respuesta aceptada

Image Analyst
Image Analyst el 20 de Feb. de 2013
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 comentarios
Sat m
Sat m el 20 de Feb. de 2013
thank you. it is working now. thank you
Zahra Saman
Zahra Saman el 12 de Abr. de 2018
please help me is this problem

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by