Tuesday, May 27, 2008

Assignment 5

1) A= zeros(256);
for x=1:256;
for y=1:256;
if((x-128)^2+(y-128)^2<=50^2) A(x,y)=1; endif; endfor; endfor; imshow(A)














2. Use Octave to compose the picture of fig 6.4 in the text

A=zeros(256);B=zeros(256);C=zeros(256);
for x=1:256;
for y=1:256;
if (x-93)^2+(y-128)^2<=50^2; A(x,y)=1;
endif;
if (x-153)^2+(y-93)^2<= 50^2; B(x,y)=1; endif; if (x-153)^2+(y-153)^2<= 50^2; C(x,y)=1; endif; endfor;
endfor;
X(:,:,1)=A*255; X(:,:,2)=B*255; X(:,:,3)=C*255;
imshow (X)



3. big T ( octave commands from class notes)

bigT = 255*ones(256);
bigT(30:79,64:191) = zeros(50,128);
bigT(50:199,111:146)= zeros(160,36);
imshow(bigT)











Shewed bigT


bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);
function retval=newy(x,y,s);
retval=y+mod(x*s,256)+1;
endfunctionfor x=1:256;
for y=1:256;y1=int32(newy(x,y,1));
if(y1>256)y1=y1-256;endif;bigT1(x,y1)=bigT(x,y);
endfor;
endfor;
imshow(bigT1)












Shewed bigT rotated by 5pi/6

bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);

bigT1=ones(256);
for x=1:256;
for y=1:256;xa=int32(mod(x*cos(5*pi/6)-y*sin(5*pi/6),256)+1);ya=int32(mod(x*cos(5*pi/6)+y*sin(5*pi/6),256)+1);bigT1(xa,ya)=bigT(x,y);
endfor;
endfor;
imshow(bigT2)









No comments: