Error using "imhist" in MATLAB 2014
I am trying to use imhist to display histogram uint8.jpg, however I am getting this error:
Error when using imhist Expected input number 1, i or X, which will be two dimensional.
Error in imhist> parse_inputs (line 278) validateattributes (a, {'Twice', '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 the image to another data class? I would appreciate any help on this.
Thank!
The reason for the error is that your RGB image and imhist can't handle it. To get around this, you can use a single pipe:
imhist(YourImage(:,:,Channel));
or convert from RGB to grayscale:
imhist(rgb2gray(YourImage));
This should work fine now.