matlab - 在 MATLAB 2014 中使用 'imhist' 时出错

标签 matlab histogram

我正在尝试使用 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
Attributes

f 2988x5312x3 47616768 uint8

我需要将我的图像转换为另一个数据类吗?我将不胜感激。

谢谢!

最佳答案

错误原因是因为你的图片是RGB的,imhist没有处理。要解决此问题,您可以使用单个 channel :

imhist(YourImage(:,:,Channel));

或从 RGB 转换为灰度:

imhist(rgb2gray(YourImage));

现在应该可以正常工作了。

关于matlab - 在 MATLAB 2014 中使用 'imhist' 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25752417/

相关文章:

python - 如何在 matplotlib 中获取当前图的 clim

matlab - 如何做一个频段?

Python Altair 如何在不更改轴刻度的情况下对直方图数据进行分箱

python - 使用直方图函数检查列表中的重复字母

javascript - D3 条形图 Axis 怪癖

matlab - 在 matlab 中评论

R 版的 scatter3(matlab)

c++ - 使用 std :array via template non-type argument? 初始化 Boost 直方图 Axis

c#-4.0 - 为什么图像二值化显示的结果较差?

matlab - 在排序向量中查找上界索引