Tuesday, June 3, 2008

assignment #5 Q 2


Q(2) Give Octave commands to draw the top part of figure 6.4 in the book(without lettering)
Ans.
rgbycm=zeros(256);
for x=1:256;
for y=1:256;
r=(x-128)^2 + (y-100)^2;
g=(x-78)^2 + (y-125)^2;
b=(x-128)^2 + (y-150)^2;
if r<=2500;
red=1;
else;
red=0;
end;
if g<=2500;
green=1;
else;
green=0;
end;
if b<=2500;
blue=1;
else;
blue=0;
end;
rgbycm(x,y,1)=red;
rgbycm(x,y,2)=green;
rgbycm(x,y,3)=blue;
end;
end;
imshow(rgbycm)

No comments: