comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Using FFT convolve() : centering error?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Using FFT convolve() : centering error? [message #68418] Tue, 27 October 2009 06:45
Chris W is currently offline  Chris W
Messages: 12
Registered: May 2007
Junior Member
On Oct 26, 4:51 pm, Kyle <kdpen...@gmail.com> wrote:
> Hi everyone,
>
> I'm trying to convolve a fake image with a point spread function (PSF)
> using FFT.  The IDL function I'm using is this:http://idlastro.gsfc.nasa.gov/ftp/pro/image/convolve.pr o
>
> Basically, my problem is this: I have an image array, and a PSF
> array.  The PSF is *not* symmetric in it's array (that is: the maximum
> value of the PSF does not occur at FLOOR((X-1)/2) and FLOOR((Y-1)/2),
> where X and Y are the number of elements in each dimension).  To me,
> this means that everything in the fake image should shift after
> convolving with the PSF.  However, that is not the case.  Here's an
> example:
>
> image = dblarr(679,695) ; the psf is an array that's 678x694
> image[100,100]=100.
> test = convolve(image, psf)
> print, array_indices(test, where(test eq max(test)))
> ; the output is 100, 100, exactly where it was before
>
> I would expect the maximum of the fake image array to have shifted
> because the PSF is not centered in it's array.  To complicate things,
> I can compute the convolution with the conjugate of the PSF array
> (this is done by adding the /correlate keyword):
>
> test = convolve(image, psf, /correlate)
> print, array_indices(test, where(test eq max(test)))
> ; the output is 101, 101!  The maximum shifted, exactly like I
> expected it too!
>
> I think I know what's going on -- convolve() is definitely calculating
> the centers of both arrays incorrectly -- but I can't figure out how
> to fix it.  Does anyone have experience with convolve() or convolution
> by FFT?
>
> Thanks!

Could the shift be due to different sizes of the image and the psf?
Re: Using FFT convolve() : centering error? [message #68423 is a reply to message #68418] Mon, 26 October 2009 16:10 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Oct 26, 5:51 pm, Kyle <kdpen...@gmail.com> wrote:
> Hi everyone,
>
> I'm trying to convolve a fake image with a point spread function (PSF)
> using FFT.  The IDL function I'm using is this:http://idlastro.gsfc.nasa.gov/ftp/pro/image/convolve.pr o
>
> Basically, my problem is this: I have an image array, and a PSF
> array.  The PSF is *not* symmetric in it's array (that is: the maximum
> value of the PSF does not occur at FLOOR((X-1)/2) and FLOOR((Y-1)/2),
> where X and Y are the number of elements in each dimension).  To me,
> this means that everything in the fake image should shift after
> convolving with the PSF.  However, that is not the case.  Here's an
> example:
>
> image = dblarr(679,695) ; the psf is an array that's 678x694
> image[100,100]=100.
> test = convolve(image, psf)
> print, array_indices(test, where(test eq max(test)))
> ; the output is 100, 100, exactly where it was before
>
> I would expect the maximum of the fake image array to have shifted
> because the PSF is not centered in it's array.  To complicate things,
> I can compute the convolution with the conjugate of the PSF array
> (this is done by adding the /correlate keyword):
>
> test = convolve(image, psf, /correlate)
> print, array_indices(test, where(test eq max(test)))
> ; the output is 101, 101!  The maximum shifted, exactly like I
> expected it too!


That probably arises when the FFT is shifted.
A shift of nx/2 works well for even sized array but
there may be an offset of 1 with odd-sized array.

I suggest you figure that out by using a delta function
PSF and track down.

In particular, the last line of convolve:

return, shift( conv, sc[1], sc[2] )

What happens if you shift by -sc[1] and -sc[2] instead?
This is not equivalent for odd-sized arrays (and is equivalent
for even sized).

Ciao,
Paolo





>
> I think I know what's going on -- convolve() is definitely calculating
> the centers of both arrays incorrectly -- but I can't figure out how
> to fix it.  Does anyone have experience with convolve() or convolution
> by FFT?
>
> Thanks!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FOR loops and efficiency
Next Topic: quadtree algorithm

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:45:37 PDT 2025

Total time taken to generate the page: 0.00516 seconds