Info
この質問は閉じられています。 編集または回答するには再度開いてください。
i am executing the code below in which i am getting the error"Index exceeds matrix dimensions. Error in principale_peppers (line 7) g=X(:,:,2)/255;" how to solve it. can anyone solve it for me
1 回表示 (過去 30 日間)
古いコメントを表示
X=imread('d:\images\peppers.bmp'); X=double(X);
[l1,l2,l3]=size(X);
r=X(:,:,1)/255;
g=X(:,:,2)/255;
b=X(:,:,3)/255;
%figure(1),imshow(r)figure(2),imshow(g)figure(3),imshow(b)
r2=zeros(l1,l2,3); r2(:,:,1)=r;
g2=zeros(l1,l2,3); g2(:,:,2)=g;
b2=zeros(l1,l2,3); b2(:,:,3)=b; m1=240;
0 件のコメント
回答 (1 件)
Stephen23
2015 年 3 月 3 日
編集済み: Stephen23
2015 年 3 月 3 日
The imread documentation states: The return value A is an array containing the image data. If the file contains a grayscale image, A is an M-by-N array. If the file contains a truecolor image, A is an M-by-N-by-3 array.
The image is likely not in color, but saved as grayscale or indexed. If an image is grayscale or indexed, then it has only size M*N, and does not have a page for each of R, G and B. Only truecolor images have size M*N*3. You can read more in the documentation:
To demonstrate this I created a small image (attached) and read it into MATLAB, where it is clear that it only has one page:
>> imread('test.bmp')
ans =
1 1 1 1 1 1
1 1 0 1 1 1
1 0 0 1 1 1
1 1 0 0 0 1
1 1 0 0 0 1
1 1 0 1 0 1
1 1 0 1 0 1
1 0 0 0 0 0
1 1 1 1 1 1
Depending on what kind of image it is you might need to get the map value from imread too.
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!