Method 1:
function [smallimage]=shrink1(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=0:(Mp-1);
for j=0:(Np-1);
for x=floor(i/f):ceil((i+1)/f)-1;
for y=floor(j/f):ceil((j+1)/f)-1;ival=picture(x+1,y+1,:);
if (x<(i/f)); ival=ival*(1+x-(i/f)); end; if ((x+1)>(i+1)/f);
ival=ival*(1-(x+1)+((i+1)/f));
end;
if (y<(j/f)); ival=ival*(1+y-(j/f)); end; if ((y+1)>(j+1)/f);
ival=ival*(1-(y+1)+((j+1)/f));
end;
smallimage(i+1,j+1,:)=smallimage(i+1,j+1,:)+ival;
end;
end;
smallimage(i+1,j+1,:)=smallimage(i+1,j+1,:)*(f^2);
end;
end;
endfunction;
Octave commands to display images:
A=imread('picturename.jpg');
B=shrink1(A,f); #where f represents the percent of shrinkage
imshow(double(B)/255);
Method 2:
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,j,:)=picture(a,b,:);
end;
end;
endfunction;
Octave commands to display images:
A=imread('picturename.jpg');
B=shrink2(A,f); #where f represents the percent of shrinkage
imshow(double(B)/255);
Method 3:
function [smallimage]=shrink3(picture,f);
picture=double(picture);
Mp=floor(size(picture,1)*f);
Np=floor(size(picture,2)*f);
for i=0:(Mp-1);
for j=0:(Np-1);
a=i/f;
b=j/f;
r=floor(a);
s=floor(b);
if (r>0) & (r<256)>0) & (s<256); for k=1:3; smallimage(i,j,k)=[1-a+r,a-r]*[picture(r,s,k),picture(r,s+1,k); picture(r+1,s,k), picture(r+1,s+1,k)]*[1-b+s; b-s];
end;
end;
end;
end;
endfunction;
Octave commands to display images:
A=imread('picturename.jpg');
B=shrink3(A,f); #where f represents the percent of shrinkage
imshow(double(B)/255);
Question #1
Average over all Pixels in the Destination Point
Method 1: Spectrum
largeimage=double(imread("spectrum.jpg"));
f=0.75;
Mp=floor(size(largeimage,1)*f);
Np=floor(size(largeimage,2)*f);
smallimage(:,:,1)=zeros(Mp,Np);
smallimage(:,:,2)=zeros(Mp,Np);
smallimage(:,:,3)=zeros(Mp,Np);
for i=0:(Mp-1);
for j=0:(Np-1);
for x=floor(i/f):ceil((i+1)/f)-1;
for y=floor(j/f):ceil((j+1)/f)-1;
ival=largeimage(x+1,y+1,:);
if (x<(i/f));ival=ival*(1+x-(i/f)); end; if ((x+1)>(i+1)/f);
ival=ival*(1-(x+1)+((i+1)/f));
end;
if (y<(j/f));ival=ival*(1+y-(j/f)); end; if ((y+1)>(j+1)/f);
ival=ival*(1-(y+1)+((j+1)/f));
end;
smallimage(i+1,j+1,:)=smallimage(i+1,j+1,:)+ival;
end;
end;
end;
end;
smallimage=smallimage*f^2;
imshow(double(smallimage)/255);
f=0.75;
f=0.25;
f=0.1
Method 1:Picture1
largeimage=double(imread("picture1.jpg"));
f=0.75; (continue by following the commands Under Method 1 above)
f=0.75;
f=0.25;
f=0.1;
Method 1:Picture2
largeimage=double(imread("picture2.jpg"));
f=0.75; (continue by following the commands Under Method 1 above)
f=0.75;
f=0.1;
Take the Nearest Neighbour
Method 2:Spectrum
largeimage=imread("spectrum.jpg");
f=0.75;
Mp=floor(size(largeimage,1)*f);
Np=floor(size(largeimage,2)*f);
smallimage(:,:,1)=zeros(Mp,Np);
smallimage(:,:,2)=zeros(Mp,Np);
smallimage(:,:,3)=zeros(Mp,Np);
for i=1:Mp;
for j=1:Np;
a=round(i/f);
b=round(j/f);
smallimage(i,j,:)=largeimage(a,b,:);
end;
end;
imshow(double(smallimage)/255);
Method 2: Picture1
largeimage=double(imread("picture1.jpg"));f=0.75; (continue by following the commands Under Method 2 above)
f=0.75;
f=0.25;
f=0.1;
Method 2: Picture2
largeimage=double(imread("picture2.jpg"));
f=0.75; (continue by following the commands Under Method 2 above)
f=0.75;f=0.25;
f=0.1;
Take a Bilinear Interpolation of the Larger Image
Method 3: Spectrum
largeimage=double(imread("spectrum.jpg"));
f=0.75;
Mp=floor(size(largeimage,1)*f);
Np=floor(size(largeimage,2)*f);
for i=0:Mp-1;
for j=0:Np-1;
a=i/f;
b=j/f;
r=floor(a);
s=floor(b);
if (r>0) & (r<256)>0) & (s<256); k="1:3;" f="0.75;" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiB7yEo5bCy00LsEN8K9JQkJP3K0azGOwd3GkJm9_k38I0MJ97be_04tL4mT7w4N20hui_xb57SX9-GTsfQatUwgVSL-L0VPZMAVgWvhJBHssR0j0a6dx_deRzXOS1dxeKT5Z2xkoZw_kVR/s1600-h/Ass+7+Spectrum+Method+3+F%3D0.75.JPG">
f=0.25;
f=0.1;
Method 3: Picture1
largeimage=double(imread("picture1.jpg")); f=0.75; (continue by following the commands Under Method 3 above)
f=0.75;
f=0.25;
f=0.1;
Method 3: Picture2
largeimage=double(imread("picture2.jpg")); f=0.75; (continue by following the commands Under Method 3 above)
f=0.75;
No comments:
Post a Comment