Tuesday, May 27, 2008

Assignment # 5

Problem #1

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

















Problem # 2

A1=zeros(256);
for x=1:256;
for y=1:256;
if (x-95.3)^2+(y-128)^2<=2500
A1(x,y)=1;
endif
endfor
endfor;
A2=zeros(256);
for x=1:256; for y=1:256;
if (x-142.6)^2+(y-104)^2<=2500
A2(x,y)=1;
endif
endfor
endfor;
A3=zeros(256);
for x=1:256; for y=1:256;
if (x-142.6)^2+(y-170)^2<=2500
A3(x,y)=1;
endif
endfor
endfor;
B(:,:,2)=255*A1;
B(:,:,1)=255*A2;
B(:,:,3)=255*A3;
imshow(B)






















Problem # 3

Big T skewed by s =2

bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);
for x =1:256;
for y =1:256;
y1=rem(2*x+y,256)+1;
bigT1(x,y)=bigT(x,y1);
endfor;
endfor;
imshow(bigT1)


















Big T skewed by s = 2, and turned by 3*pi/4

bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);
for x =1:256
for y =1:256
y1=mod(2*x+y,256)+1;
bigT1(x,y) = bigT(x,y1);
endfor
endfor;
for x =1:256
for y =1:256
x2=x*cos(3*pi/4)-y*sin(3*pi/4);
y2=x*sin(3*pi/4)+y*cos(3*pi/4);
x3 = round(x2);
y3 = round(y2);
bigT2(mod(x3,256)+1,mod(y3,256)+1)=bigT1(x,y);
endfor
endfor
imshow(bigT2)






No comments: