Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Torsten

Posts: 1,439
Registered: 11/8/10
Re: BILINEAR INTERPOLATION HELP NEEDED
Posted: Mar 24, 2014 5:20 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

devarajr07@gmail.com wrote in message <d44ea411-b4fb-4931-be0d-4eec7a3b43e4@googlegroups.com>...
> 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
>
> a=imread('peppers.png');
> 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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.