help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bilinear interpolation on 2D matrix


From: AGD
Subject: Bilinear interpolation on 2D matrix
Date: Fri, 9 Apr 2010 11:42:53 -0800 (PST)

I am trying to implement bilinear interpolation on this 3X3 matrix after
scaling it by a factor 'a'. I am not getting the appropriate output. Also i
am not able to store all the interpolated values as different variables. 

%octave code for bilinear interpolation in x-direction

>a=0.5;
>x=[1 2 3;4 5 6;7 8 9];
>y=[2 2 1;3 1 2;4 2 3];
>c=0;
>x1=transpose(x);
>y1=transpose(y);
>for m=1:3
   >n=3;
   >z=x(m,1:n)
   >s=numel(z)/a;
   >t=((c*6)+1:(c*6)+6)*a;
   >for b=1:s
      >if floor(t(b))==0
      >r(b)=y1(1)*t(b);
      >else
      >p=(1-(t(b)-floor(t(b))))+y1(x1(floor(t(b))));
      >q=(t(b)-floor(t(b)))*y1(x1(ceil(t(b))));
      >r(b)=p+q;
      >end
   >end
   >c=c+1;
>end
>stem(t,r);
>r=[r(1):r(6);r(7):r(12);r(13):r(18)];


-- 
View this message in context: 
http://n4.nabble.com/Bilinear-interpolation-on-2D-matrix-tp1819797p1819797.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]