Reputation: 90
I am trying to use imhist to display the histogram of a uint8 .jpg, however I am getting this error:
Error using imhist Expected input number 1, I or X, to be two-dimensional.
Error in imhist>parse_inputs (line 278) validateattributes(a, {'double','uint8','int8','logical','uint16','int16','single','uint32', 'int32'}, ...
Error in imhist (line 60) [a, n, isScaled, top, map] = parse_inputs(varargin{:});
Here is my image information:
whos f Name Size Bytes Class
Attributesf 2988x5312x3 47616768 uint8
Do I need to convert my image to another data class? I would appreciate any help on this.
Thanks!
Upvotes: 4
Views: 7806
Reputation: 13945
The cause of error is because your image is RGB and imhist does not deal with that. To work around this you can either use a single channel:
imhist(YourImage(:,:,Channel));
or convert from RGB to grayscale:
imhist(rgb2gray(YourImage));
That should work fine now.
Upvotes: 14