matlab中有一个函数imhist怎么用?

来源:百度知道 编辑:UC知道 时间:2024/05/10 20:14:03
matlab中有一个函数imhist,是显示什么样的图形的直方图的?我用的带tif后缀的彩色图,则出现错误提示,可是用灰度图像呢 有的显示 有的不显示,不知道是什么原因?
是不是这个函数只能显示灰度的图像啊 ,那这样的灰度有什么要求吗?
L=imread('lily.tif');
subplot(1,2,1);
imhist(L);
上面是我的输入 下面是错误,不明白为什么 有些彩图可以输出 可是有的不可以
??? Error using ==> c:/matlab6p5/toolbox/images/images/private/checkinput (check_attributes)
Function imhist expected its first input argument, I or X,
to be two-dimensional.

Error in ==> C:\MATLAB6p5\toolbox\images\images\private\checkinput.m
On line 37 ==> check_attributes(A, attributes, function_name, variable_name, ...

Error in ==> C:\MATLAB6p5\toolbox\images\images\imhist.m (parse_inputs)
On line 173 ==> checkinput(a, 'double uint8 logical uint16', '2d', mfilename, 'I or X', 1);

Error in ==> C:\MATLAB6p5\toolbox\images\images\imhist.m
On line 49 ==> [

因为imhist只能对灰度图像画直方图,所以那样直接画是不行的,我给你改了一下,你再试试:

L=imread('lily.tif');
L=rgb2gray(L);
subplot(1,2,1);
imhist(L);

这样你在看看