필터 지우기
필터 지우기

why does the green in RGB come out yellow

조회 수: 1 (최근 30일)
yair suari
yair suari 2011년 7월 31일
i want to use the following code to demonstrate what RGB is but somehow the green comes yellow. anyone knows why is that?
x=-1:.01:1
y=-1:.01:1
[X,Y]=meshgrid(x,y);
Z=sqrt(X.^2+Y.^2);
Z(Z>1)=1;
R=ones(330,330);
G=ones(330,330);
B=ones(330,330);
R(1:201,1:201)=Z;
G(76:276,76:276)=Z;
B(1:201,126:326)=Z;
img=cat(3,R,G,B);
h=image(img)
thanks in advance yair

채택된 답변

the cyclist
the cyclist 2011년 7월 31일
For all three colors, you are not getting RGB, but the complementary colors cyan,magenta,yellow.
Here's RGB corrected, but with a black background:
x=-1:.01:1;
y=-1:.01:1;
[X,Y]=meshgrid(x,y);
Z=sqrt(X.^2+Y.^2);
Z(Z>1)=1;
R=zeros(330,330);
G=zeros(330,330);
B=zeros(330,330);
R(1:201,1:201) = 1-Z;
G(76:276,76:276) = 1-Z;
B(1:201,126:326) = 1-Z;
figure
img=cat(3,R,G,B);
h=image(img)

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by