Why does this bilinear interpolation algorithm have two Y(i,j) outputs (i.e. Y(i,j)=I(ceil(y),ceil(x)) and Y(i,j)=(y-y2)*P+(y1-y)*Q )? How difference are they ?
Show older comments
What is the meaning of each bolded-lines in the traditional bilinear interpolation algorithm source code shown below ? Why these TWO 'outputs' and HOW different are they ? Can you please explain with an illustration, if possible ?
----------------------------------- clc close all clear all I=imread('LENNA64.bmp'); [originheight,originwidth]=size(I); height=4*originheight; width=4*originwidth;
Y=zeros(height,width);
[height,width]=size(Y); hscale=originheight/height; wscale=originwidth/width;
for i=1:height y=hscale*i; for j=1:width x=wscale*j;
if(floor(x)==0)||(floor(y)==0)||(ceil(x)==originwidth)||(ceil(y)==originheight)
*Y(i,j)=I(ceil(y),ceil(x));*
else
x1=floor(x);
x2=x1+1;
y2=floor(y);
y1=y2+1;
N1=I(y2,x1);
N2=I(y2,x2);
N3=I(y1,x2);
N4=I(y1,x1);
Q=(x2-x)*(N1)+(x-x1)*(N2);
P=(x2-x)*(N4)+(x-x1)*(N3);
*Y(i,j)=(y-y2)*P+(y1-y)*Q;*
end
end
end
Y=uint8(Y); figure;imshow(Y);
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!