fft and least sqaues problem [message #81144] |
Tue, 14 August 2012 07:06 |
rogass
Messages: 200 Registered: April 2008
|
Senior Member |
|
|
Hi Folks,
I try to estimate the subpixelshifts if an image is compared with its shifted represenetation, but something is going wrong. Maybe somebody can help me.
s=size(im,/dim)*1.
im1 =im
dx=.25
dy=.3
im2=image_shift(im1,dx,dy);more precise then interpolate(im,findgen(s[0])+dx,findgen(s[1])+dy,/grid,/cubi c)
fim1=fft(im1,-1)
fim2=fft(im2,-1)
corr=fim1*conj(fim1)/abs(fim1*fim2)
corr=shift(corr,s/2)
phase=atan(imaginary(corr)/real_part(corr))
wx=(findgen(s) mod s[0])*2.*!pi/s[0]
wy=(rebin(findgen(1,s[1]),s))*2.*!pi/s[1]
r=5;fitting radius
phase2=phase[s[0]/2 - r : s[0]/2 + r,s[1]/2 - r : s[1]/2 + r]
wx2=wx[s[0]/2 - r : s[0]/2 + r,s[1]/2 - r : s[1]/2 + r]
wy2=wy[s[0]/2 - r : s[0]/2 + r,s[1]/2 - r : s[1]/2 + r]
print,la_least_squares(transpose([[wx2[*]],[wy2[*]]]),phase2 [*])
The last line should give dx and dy but its erroneous. I don't really know why!
Thanks in advance
CR
|
|
|