Transforming a matrix in an image
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
Hi community,
I am transforming a matrix in an image, but when I try to see the green and blue components of the image a get the error Index exceeds matrix dimensions.
dmin1=2; 
n=15;
A=ones(n); 
A(2:dmin1:end,2:dmin1:end)=0;
im = imshow(A,[])
%im = image(im,'CDataMapping','scaled')
...
... % code that add some colors to im
R=im(:,:,1)
G=im(:,:,2)
B=im(:,:,3)
What I'm doing wrong?
댓글 수: 4
채택된 답변
  Image Analyst
      
      
 2020년 8월 10일
        First of all, your image is A, not im.  im is what imshow returns and it is the handle to an image object, not an actual image itself.  Secondly, you declared A as a 2-D gray scale image, not a 3-D color image.  You'd need to make A like this:
A=ones(n, n, 3); 
A(2:dmin1:end, 2:dmin1:end, :) = 0;
R = A(:,:,1)
G = A(:,:,2)
B = A(:,:,3)
or
[R, G, B] = imsplit(A);
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
![Free V-Bucks Generator [UPDATE]](/responsive_image/100/100/0/0/0/cache/matlabcentral/profiles/19163365_1597055879210.png)


