How to generate image matrix Red Green Blue Yellow Green

조회 수: 8 (최근 30일)
Jjet Jumbo
Jjet Jumbo 2012년 11월 19일
Generate the following image by defining image matrix:
Red Green Blue Yellow Green.
B(1:100,1:100,1:100,1:00,1:3)=0;
imshow (B)
B(1:50,1:50,1) =1;
B(51:100,51:100,2)=1;
imshow(B)
I am trying to get a 3x3 with the specified colors; Red Green Blue Yellow Green. It's not working, it gives error.

답변 (2개)

Image Analyst
Image Analyst 2012년 11월 19일
Is this what you're looking for:
redChannel = zeros(100, 100, 'uint8');
greenChannel = zeros(100, 100, 'uint8');
blueChannel = zeros(100, 100, 'uint8');
redChannel(1:50,:) = 255;
greenChannel(:, 1:50) = 255;
blueChannel(51:100, 51:100) = 255;
coloredImage = cat(3, redChannel, greenChannel, blueChannel);
imshow(coloredImage)
  댓글 수: 6
Cesar
Cesar 2013년 2월 2일
편집: Walter Roberson 2013년 2월 2일
Can you please complete it to create the 3 X 3 image:
Red Yellow
Green
Green Blue
Image Analyst
Image Analyst 2013년 2월 2일
Cesar, you can see my solution and the modifications to it to do what you want should be straightforward. Just change the row and column ranges.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2012년 11월 19일
B(1:100,1:100,1:100,1:00,1:3)=0 tries to define a 5 dimensional array in which the fourth dimension is empty. 1:00 is empty. Perhaps you meant 1:100 .
RGB matrices are 3 dimensional.
You may wish to use zeros() to initialize the matrix.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by