4

I have to obtain a high resolution image from a low resolution image. This can be achieved using interpolation methods. I know in matlab imresize and interp2 functions will perform the task, but I have to write code without using any built in functions. I understand how bilinear interpolation works but i can't seem to piece it together in my code. I will be grateful for any help and suggestions.

Here is my code so far:

clear all; close all; clc;

input_im=imread('superman.png');
im=rgb2gray(input_im);
%subplot(1,2,1), imshow(input_im), title('Original Image');
%subplot(1,2,2), imshow(im), title('Gray Scale Input Image');

[m,n]=size(im); %obtain the size of gray scale image
S = input('  Now Enter Value : ');
Scale1 = floor(S);
Scale2 = floor(S);
scale = [Scale1, Scale2];

Oim=size(im);
Nim=max(floor(scale.*Oim(1:1)),1);

for i=1:Nim-1
    for j=1:Nim-1

       Q11=
       Q21=
       Q12=
       Q22=
       R1=((x2-x)/(x2-x1))*Q11+((x-x1)/(x2-x1))*Q21;
       R2=((x2-x)/(x2-x1))*Q12+((x-x1)/(x2-x1))*Q22;
       P=((y2-y)/(y2-y1))*R1+((y-y1)/(y2-y1))*R2;
    end
end
Shai
  • 111,146
  • 38
  • 238
  • 371
user1347827
  • 41
  • 1
  • 1
  • 3
  • 1
    It is best not to [use `i` and `j` as variable names in matlab](http://stackoverflow.com/questions/14790740/using-i-and-j-as-variables-in-matlab) – Shai May 16 '13 at 07:31

1 Answers1

-1

The code behind interp2 is available. Just write >> edit interp2 in the command window and you can check out how they implemented it.

Shai
  • 111,146
  • 38
  • 238
  • 371
mola
  • 1,120
  • 1
  • 8
  • 22