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: sub-pixel shifting of a matrix
Replies: 14   Last Post: Feb 7, 2013 12:23 PM

 Messages: [ Previous | Next ]
 Shalin Mehta Posts: 6 Registered: 9/17/09
Re: sub-pixel shifting of a matrix
Posted: Sep 17, 2009 5:33 AM

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 <h8ss9r\$jhf\$1@fred.mathworks.com>...
> 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

Date Subject Author
9/17/09 Shalin Mehta
9/17/09 Shalin Mehta
10/30/09 Dumebi Okwechime
2/24/10 Shalin Mehta
2/24/10 Matt J
2/25/10 Rajesh
2/25/10 Matt J
2/25/10 Matt J
2/26/10 Rajesh
2/6/13 Bruno Luong
2/6/13 Matt J
2/6/13 Bruno Luong
2/7/13 Matt J
2/7/13 Bruno Luong