Just found a useful solution: Use interp2 with '*linear' option. Works factor of 2.5 faster than imtransform. Any other ideas?
best shalin "Shalin Mehta" <shalinDOTmehtaHATESSPAM@gmail.com> wrote in message <firstname.lastname@example.org>... > Hello world, > > I have data defined over a grid, e.g. > [xx yy]=meshgrid(-1:0.1:1); %each pixel represents distance of 0.1 > data=xx.^2+yy.^2 ; > > I need to translate this data by sub-pixel distances which will inevitably involve interpolation. I can live with linear interpolation as the data is sampled quite finely. I am using imtransform to achieve this. The shifted-data need to be obtained only over the original grid. I want extrapolated locations to be zero. > > xshift=0.235; yshift=-0.95; %Since shift is finer than sampling, sub-pixel shifting is required. > xdata=[1 wt]; > ydata=[1 ht]; > T=maketform('affine',[1 0 0; 0 1 0; xshift yshift 1]); > shifteddata=imtransform(data,T,'bilinear','XData',xdata,'YData',ydata); > > Results are satisfactory but slow as this shifting happens in the inner-most loop. > Can anyone suggest a method that involves direct indexing and hence would be faster? Any neat algorithm published in the literature for sub-pixel translation? > > best > Shalin