我正在尝试使用 imhist 来显示 uint8 .jpg 的直方图,但是我收到了这个错误:
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{:});
这是我的图片信息:
whos f Name Size Bytes Class
Attributesf 2988x5312x3 47616768 uint8
我需要将我的图像转换为另一个数据类吗?我将不胜感激。
谢谢!
最佳答案
错误原因是因为你的图片是RGB的,imhist没有处理。要解决此问题,您可以使用单个 channel :
imhist(YourImage(:,:,Channel));
或从 RGB 转换为灰度:
imhist(rgb2gray(YourImage));
现在应该可以正常工作了。
关于matlab - 在 MATLAB 2014 中使用 'imhist' 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25752417/