email@example.com wrote in message <firstname.lastname@example.org>... > 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).