Image Processing Using Matlab:BilinearInterpolation without using Inbuit Function
Problem:
Implement BilinearInterpolation(image, x, y) to compute the linearly interpolated pixel value at (x, y). Both x and y are continuous values.
Main Function:
clear
close all
input = imread('Moire_small.jpg');
input1=rgb2gray(input);
figure,imshow(input1),title('original');
output = imresize(input1,4,'nearest');
out2=BilinearInterpolation(input1);
figure,imshow(output),title('Bilinear');
Bilinear Interpolation:
function[out1,out2]=BilinearInterpolation(input)
out1=input;
out2=input;
for i = 1:size(input, 1)-4
for j = 1:size(input, 2)-4
for k=1:3
for l=1:3
out1(i+k,j+l)=(1-k)*(1-l)*(input(i,j))+(k*(1-l)*input(i+4,j))+((1-k)*l*input(i,j+4))+(k*l*input(i+4,j+4));
out2(i+k,j+l)=input(i+k+1,j+k+1);
end
end
j=j+4;
end
i=i+4;
end