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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With