2011-11-20 120 views
0

这里是我的代码:rgb2gray返回一个空白图像,而图像(​​I)返回正确的图像

I = imread(fullfile(vl_root,'data','cup1.jpg')) ; 
%returns a picture of a cup 
image(I) 
colormap gray; 
%returns a white blank picture 
image(rgb2gray(I)) 

奇怪的是,下面的代码工作对我来说:

I = getsnapshot(vid); 
%returns a picture of a snapshot 
    image(I) 
    colormap gray; 
    %returns a black and white picture 
    image(rgb2gray(I)) 

从我只能假设两种图像类型之间存在某种差异,但似乎无法确定原因。他们都是

有什么想法吗?

回答

0

我运行你的代码,显然'colormap gray'会创建一个尺寸为64x3的色图,这对于8位灰度图像来说是不够的,这反过来会使颜色看起来被截断。 我用

 colormap([linspace(0,1,255)' linspace(0,1,255)' linspace(0,1,255)']) 

它工作正常。

我没有相机,所以我无法验证第二部分,但也许相机图像是低强度的?