deany 发表于 2006-4-11 16:26

在Matlab图像处理中遇到的问题

<P>请师兄师姐帮忙一下:(想得到原始图像的原始直方图)<BR>运行下面程序<BR>I=imread('H:\10.jpg');<BR>imshow(I)<BR>figure,imhist(I,64)<BR>命令窗口就出现下面的提示:<BR><BR>??? Error using ==&gt; g:/matlab/toolbox/images/images/private/checkinput (check_attributes)<BR>Function imhist expected its first input argument, I or X,<BR>to be two-dimensional.</P>
<P>Error in ==&gt; G:\Matlab\toolbox\images\images\private\checkinput.m<BR>On line 37==&gt; check_attributes(A, attributes, function_name, variable_name, ...</P>
<P>Error in ==&gt; G:\Matlab\toolbox\images\images\imhist.m (parse_inputs)<BR>On line 173==&gt; checkinput(a, 'double uint8 logical uint16', '2d', mfilename, 'I or X', 1);</P>
<P>Error in ==&gt; G:\Matlab\toolbox\images\images\imhist.m<BR>On line 49==&gt; = parse_inputs(varargin{:});<BR><BR>请问这要怎么解决呢?谢谢~!</P>

sxf372284 发表于 2006-4-11 17:11

<P>你的.jpg是应该是彩色图像吧,那应该不是2维的吧,好象只有灰度图像才有直方图啊!</P>

happy 发表于 2006-4-11 21:17

回复:(deany)在Matlab图像处理中遇到的问题

<P>你看看用imread得到I是不是三维的<BR>三维的不能用imhist ,你按楼上说的办就行了。</P>
<P>两种办法:<BR>1.转为灰度图<BR>J = gray(I)<BR>imhist(J);</P>
<P>2.</P>
<P>imhist(I(:,:,1)); % imhist of red component.<BR>imhist(I(:,:,2)); % imhist of green component.<BR>imhist(I(:,:,3)); % imhist of blue component. </P>
页: [1]
查看完整版本: 在Matlab图像处理中遇到的问题