Saturday, June 7, 2008
Assignment #7
function smallimage=shrink2(largeimage,f);
Mp=floor(size(largeimage,1)*f-1);
Np=floor(size(largeimage,2)*f-1);
smallimage(:,:,1)=zeros(Mp-1,Np-1);
smallimage(:,:,2)=zeros(Mp-1,Np-1);
smallimage(:,:,3)=zeros(Mp-1,Np-1);
for i=1:(Mp-1)
for j=1:(Np-1)
a=round(i/f);
b=round(j/f);
smallimage(i,j,:)=largeimage(a,b,:);
end;
end;
endfunction;
A=imread("image.jpg");
B=shrink2((double(A)/255),f);
function smallimage=shrink3(largeimage,f)
Mp=floor(size(largeimage,1)*f);
Np=floor(size(largeimage,2)*f);
smallimage(:,:,1)=zeros(Mp-1,Np-1);
smallimage(:,:,2)=zeros(Mp-1,Np-1);
smallimage(:,:,3)=zeros(Mp-1,Np-1);
for i=1:(Mp-1);
for j=1:(Np-1);
a=i/f;
b=j/f;
r=floor(a);
s=floor(b);
for k = 1:3;
smallimage(i,j,k)=[1-a+r, a-r]*double([largeimage(r,s,k),largeimage(r,s+1,k);largeimage(r+1,s,k),largeimage(r+1,s+1,k)])*[1-b+s;b-s];
end;
end;
end;
endfunction;
A=imread("image.jpg");
B=shrink3((double(A)/255),0.75);
Subscribe to:
Post Comments (Atom)
1 comment:
there is definitely a problem with the average color shrink method (the first method). What is going on that the pictures are so warped?
Post a Comment