Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: BILINEAR INTERPOLATION HELP NEEDED
Replies: 14   Last Post: Mar 24, 2014 5:20 AM

 Messages: [ Previous | Next ]
 Torsten Posts: 1,717 Registered: 11/8/10
Re: BILINEAR INTERPOLATION HELP NEEDED
Posted: Mar 24, 2014 5:20 AM

> Hi Torsten,the logic what you have told for bilinear interpolation of 4X4 matrix,I applied samething for 256X256. Initially i have taken some coefficients from an image try to find the remaining coefficients but i'm not getting correct interpolated values please check the below program ,the logic is correct or not...
>
> %Bilinear interpolation
>
> b3=imresize(a,[64,64]);
> b=rgb2gray(b3);
> for i=1:32
> for j=1:32
> c(i,j)=b(2*i,2*j);
> end
> end
> for i=1:64
> for j=1:64
> if ((mod(i,2)==1) ||(mod(j,2)==1))
> q(i,j)=b(i,j);
> end
> end
> end
>
> [m n]=size(q);
>
> k=1;
> for i=1:m
> for j=1:n
> if (q(i,j)==0)
> v(k)=i;
> r(k)=j;
> k=k+1;
> end
> end
> end
>
> for i=1:1
> for j=1:1024
> M1(i,j)=v(j);
> M2(i,j)=r(j);
> M3(i,j)=v(j)*r(j);
> M4(i,j)=1;
> end
> end
> k=1;
> for i=1:1
> for j=1:1024
> M(i,k)=M1(i,j);
> M(i,k+1)=M2(i,j);
> M(i,k+2)=M3(i,j);
> M(i,k+3)=M4(i,j);
> k=k+4;
> end
> end
> k=1;
> for i=1:1024
> for j=1:4
> MM(i,j)=M(k);
> k=k+1;
> end
> end
> rh=c';
> rh1=double(rh(:));
> coeff=MM\rh1;
> w=coeff(1);
> x=coeff(2);
> y=coeff(3);
> z=coeff(4);
> for i=1:64
> for j=1:64
> MM1(i,j)=w*i+x*j+y*i*j+z;
> end
> end
> z4=round(MM1);
> imshow((z4))

Sorry, but I don't have the time to understand how your program works.
In each missing pixel point, you will have to search for the four nearest neighbours where the pixel values are known and solve a (4x4)-system of linear equations to get the unknown pixel value. I don't see that your matrix MM is (4x4).

Best wishes
Torsten.

Date Subject Author
2/2/07 dynamic.niks123@gmail.com
2/2/07 a
2/2/07 John D'Errico
2/2/07 dynamic.niks123@gmail.com
2/3/07 John D'Errico
3/5/14 devarajr07@gmail.com
3/5/14 Torsten
3/5/14 Torsten
3/11/14 devarajr07@gmail.com
3/11/14 Torsten
3/11/14 Torsten
3/12/14 devarajr07@gmail.com
3/12/14 Torsten
3/24/14 devarajr07@gmail.com
3/24/14 Torsten