Image processing rgb2gray返回空白白色图像,而图像(I)正确返回图像

Image processing rgb2gray返回空白白色图像,而图像(I)正确返回图像,image-processing,matlab,Image Processing,Matlab,这是我的密码: 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)

这是我的密码:

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))
从这一点上,我只能假设这两种图像类型之间存在某种差异,但我似乎无法找出原因。他们都是


有什么想法吗?

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

而且效果很好

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

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