I want to compute histogram for a tif image. But the regular histogram code does not accept my input. so please give me a solution
Show older comments
[Edit - format code. AU]
originalImage = imread('3-mar-08.tif');
subplot(3, 3, 1);
imshow(originalImage);
>> set(gcf, 'Position', get(0, 'ScreenSize'));
>> drawnow;
>> [pixelCount grayLevels] = imhist(originalImage);
subplot(3, 3, 2);
bar(pixelCount); title('Histogram of original image');
xlim([0 grayLevels(end)]);
??? Error using ==> iptcheckinput
Function IMHIST expected its first input, I or X, to be
two-dimensional.
Error in ==> imhist>parse_inputs at 275
iptcheckinput(a,
{'double','uint8','logical','uint16','int16','single'}, ...
Error in ==> imhist at 57
[a, n, isScaled, top, map] = parse_inputs(varargin{:});
Accepted Answer
More Answers (1)
Jos (10584)
on 27 Feb 2014
Apparently your array originalImage is not 2D. You can probably see that
ndims(originalImage)
will return 3, suggesting that the image is in RGB format. You might be able to use RGB2IND to convert it.
[X, MAP] = rgb2ind(originalImage)
imhist(X, MAP)
2 Comments
sandhya chezhian
on 27 Feb 2014
Jos (10584)
on 27 Feb 2014
a clear case of RTFM ...
doc rgb2ind
Categories
Find more on Image Segmentation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!