Wednesday, June 4, 2008

Assignment #5 Q#2

Q#2:Give octave commands to draw the top part of figure 6.4 in the book
Ans:


Octave commands:

octave-3.0.0.exe:34> C=zeros(256);
octave-3.0.0.exe:35> functionC=circle(x,y)
error: `circle' undefined near line 35 column 11
error: evaluating assignment expression near line 35, column 10
octave-3.0.0.exe:35> function C=circle(x,y)
> for i=1:256
> for j=1:256
> if (i-x)^2+(j-y)^2 <=2500
> C(i,j)=1;
> else
> C(i,j)=0;
> endif
> endfor
> endfor
> endfunction
octave-3.0.0.exe:36> C(:,:,1)=circle(142,103);
octave-3.0.0.exe:37> C(:,:,2)=circle(99,128);
octave-3.0.0.exe:38> C(:,:,3)=circle(142,153);
octave-3.0.0.exe:39> imshow(C)
octave-3.0.0.exe:40> imshow(C);

No comments: