Here's the Matlab M-file:
function [ smim2 ] = shrink2( picture, f )
Mp = floor(size(picture,1)*f);
Np = floor(size(picture,2)*f);
smim2(:,:,1)=zeros(Mp,Np);
smim2(:,:,2)=zeros(Mp,Np);
smim2(:,:,3)=zeros(Mp,Np);
for i = 0:(Mp-1);
for j = 0:(Np-1);
a=round(i/f);
b=round(j/f);
smim2(i+1,j+1,:)=picture(a+1,b+1,:);
end;
end;
smim2= (smim2)/255;
Mp = floor(size(picture,1)*f);
Np = floor(size(picture,2)*f);
smim2(:,:,1)=zeros(Mp,Np);
smim2(:,:,2)=zeros(Mp,Np);
smim2(:,:,3)=zeros(Mp,Np);
for i = 0:(Mp-1);
for j = 0:(Np-1);
a=round(i/f);
b=round(j/f);
smim2(i+1,j+1,:)=picture(a+1,b+1,:);
end;
end;
smim2= (smim2)/255;
The Matlab commands (eg. for rainbow)
rainbow=imread('rainbow.jpg');
image(shrink2(rainbow,0.75))
image(shrink2(rainbow,0.25))
image(shrink2(rainbow,0.1))
No comments:
Post a Comment