在使用imhist函数时遇到如下问题:
A = imread('D:/我的文档/My Pictures/lena.jpg','jpeg');
imhist(A)
??? Error using ==> images/private/checkinput>check_attributes
Function IMHIST expected its first input argument, I or X,
to be two-dimensional.
Error in ==> images/private/checkinput at 37
check_attributes(A, attributes, function_name, variable_name, ...
Error in ==> imhist>parse_inputs at 198
checkinput(a, {'double','uint8','logical','uint16'}, {'2d'}, mfilename, ['I or ' ...
Error in ==> imhist at 49
[a, n, isScaled, top, map] = parse_inputs(varargin{:});
原本以为它要求输入是二维的矩阵,看了一下A中的数据,一直以为就是二维的,到网上查了一下才知道原来是要求输入图像是灰度图像,而不能是RGB图像,所以加个函数rgb2gray()即可;
A = imread('D:/我的文档/My Pictures/lena.jpg','jpeg');
I = rgb2gray(A);
imhist(I)