here, i want to zoom in my image(gray) using bi-linear interpolation method, but i not able generate final out put image properly,here is the matlab code :
I = imread('house.png'); %image i want to zoom in
fact = 1.5;
[rows,cols] = size(I);
Jrows = fact * rows;
Jcols = fact * cols;
J = zeros(floor(fact * size(I)));
I = [I(1,:);I];
I = [I;I(end,:)]; %replicating boundaries.
I = [I(:,1) ,I];
I = [I,I(:,end)];
I = double(I);
for i = 2: Jrows-2
for j = 2: Jcols-2
x1 = floor(i/fact);
x2 = ceil(i/fact);
y1 = floor(j/fact); %finding neighbours
y2 = ceil(j/fact);
if x1==0
x1=1;
end
if y1==0
y1=1;
end
J(i-1,j-1) = (I(x1,y1)*(x2-i)*(y2-j) + I(x2,y1)*(i-x1)*(y2-j)+ I(x1,y2)*(x2-i)*(j-y1) + I(x2,y2)*(i-x1)*(j-y1));
end
end
figure,imshow(uint8(J)),title('zoom in image'); #final image
in this code i m getting zoom image but i lost some pixel values and i am not getting proper image.