用matlab做图像的灰度变换,指令I=rgb2gray(A)执行的时候总是报错,用的是matlab2009a程序是A=imread('D:\Cameraman.bmp');I=rgb2gray(A);subplot(2,2,1);imshow(I);title('原图');subplot(2,2,2);imhist(I);J=imadjust(I,[],[0.3 0.7],1); s

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 17:11:59
用matlab做图像的灰度变换,指令I=rgb2gray(A)执行的时候总是报错,用的是matlab2009a程序是A=imread('D:\Cameraman.bmp');I=rgb2gray(A);subplot(2,2,1);imshow(I);title('原图');subplot(2,2,2);imhist(I);J=imadjust(I,[],[0.3 0.7],1); s

用matlab做图像的灰度变换,指令I=rgb2gray(A)执行的时候总是报错,用的是matlab2009a程序是A=imread('D:\Cameraman.bmp');I=rgb2gray(A);subplot(2,2,1);imshow(I);title('原图');subplot(2,2,2);imhist(I);J=imadjust(I,[],[0.3 0.7],1); s
用matlab做图像的灰度变换,指令I=rgb2gray(A)执行的时候总是报错,用的是matlab2009a
程序是A=imread('D:\Cameraman.bmp');
I=rgb2gray(A);
subplot(2,2,1);
imshow(I);
title('原图');
subplot(2,2,2);
imhist(I);
J=imadjust(I,[],[0.3 0.7],1);
subplot(2,2,3);
imshow(J);
subplot(2,2,4);imhist(J);
报错?Error using ==> rgb2gray>parse_inputs at 82
MAP must be a m x 3 array.
Error in ==> rgb2gray at 35
X = parse_inputs(varargin{:});
Error in ==> xu1 at 2
I=rgb2gray(A);

用matlab做图像的灰度变换,指令I=rgb2gray(A)执行的时候总是报错,用的是matlab2009a程序是A=imread('D:\Cameraman.bmp');I=rgb2gray(A);subplot(2,2,1);imshow(I);title('原图');subplot(2,2,2);imhist(I);J=imadjust(I,[],[0.3 0.7],1); s
这个问题我刚好也遇到过,不一定是楼上说的这种情况,比如说把matlab画的一条曲线以bmp格式保存下来,然后imread之后A也是二维的.
我的理解是这样的,如果图像中颜色种类较少,bmp读取出来会把颜色以索引形式存下来(而不是RGB分量形式).使用 [A,map] = imread(...),A不同位置的数值在map里对应的颜色分量才是该位置的真实颜色.
对于这样的A,做灰度变换只要对map做变换就行了,如matlab里的例子:
[X,map] = imread('trees.tif');
gmap = rgb2gray(map);
figure,imshow(X,map),figure,imshow(X,gmap);