Sunday, June 8, 2008

Assignment 8 Question 5

function [smallimage] = shrink2( picture, f )
Mp = floor(size(picture,1)*f);
Np = floor(size(picture,2)*f);
smallimage(:,:,1)=zeros(Mp,Np);
smallimage(:,:,2)=zeros(Mp,Np);
smallimage(:,:,3)=zeros(Mp,Np);
for i = 1:(Mp-1);
for j = 1:(Np-1);
a=round(i/f);
b=round(j/f);
smallimage(i+1,j+1,:)=picture(a+1,b+1,:);
end;
end;
endfunction;

Octave commands:
A=imread('blueyellow.jpg');
pic1=shrink2(pic,0.2);
pic2=shrink2(pic,0.4);
pic3=shrink2(pic,0.6);
pic4=shrink2(pic,0.8);
A(52:460,77:690,:)=pic4;
A(103:409,154:613,:)=pic3;
A(154:357,231:537,:)=pic2;
A(205:306,308:460,:)=pic1;
imshow(double(A)/255);


1 comment:

Mike Zabrocki said...

Your picture looks pretty good. I haven't seen too many of these posted. This isn't exactly how I did it.