Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using 'imhist' in MATLAB 2014

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
Attributes

f 2988x5312x3 47616768 uint8

Do I need to convert my image to another data class? I would appreciate any help on this.

Thanks!

like image 748
plaingeekspeak Avatar asked Dec 09 '22 06:12

plaingeekspeak


1 Answers

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.

like image 98
Benoit_11 Avatar answered Dec 20 '22 18:12

Benoit_11