用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/07/02 02:43:52
![用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](/uploads/image/z/6987354-42-4.jpg?t=%E7%94%A8matlab%E5%81%9A%E5%9B%BE%E5%83%8F%E7%9A%84%E7%81%B0%E5%BA%A6%E5%8F%98%E6%8D%A2%2C%E6%8C%87%E4%BB%A4I%3Drgb2gray%28A%29%E6%89%A7%E8%A1%8C%E7%9A%84%E6%97%B6%E5%80%99%E6%80%BB%E6%98%AF%E6%8A%A5%E9%94%99%2C%E7%94%A8%E7%9A%84%E6%98%AFmatlab2009a%E7%A8%8B%E5%BA%8F%E6%98%AFA%3Dimread%28%27D%3A%5CCameraman.bmp%27%29%3BI%3Drgb2gray%28A%29%3Bsubplot%282%2C2%2C1%29%3Bimshow%28I%29%3Btitle%28%27%E5%8E%9F%E5%9B%BE%27%29%3Bsubplot%282%2C2%2C2%29%3Bimhist%28I%29%3BJ%3Dimadjust%28I%2C%5B%5D%2C%5B0.3+0.7%5D%2C1%29%3B+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);