Shift on 2D cuFFT C2C

Hi there,

I’m trying to do an image correlation between two images: Pattern_img of size 128x128 and Orig_img of size 256x256. One way to do that is by using the cuFFT Library.

So far, here are the steps I did:

  1. Add 0 padding to Pattern_img to have an equal size w.r.t Orig_img: (256x256)
    Ps: I know that expanding the padding up to a power of 2 (i.e 256x256 or 512x512) could be faster since cuFFT will use a different algorithm (Please tell me if I’m wrong)
  2. For simplicity, I’m using IN-PLACE C2C transform, therefore I have created my C2C plan.
  3. I perform the forward 2D transform for each image
  4. Multiply both images in the frequency domain using the appropriate complex multiplication
  5. Perform IFFT of the multiplication-result.

For illustration reasons, I have applied the same logic to smaller size images. (5x5 and 10x10).
In this case, I add 0 padding up to a size of 10x10 ( I expect to be slower but with the correct result). The rest of the steps are the same using IN-PLACE C2C FFT.
Here is the result of my real-values:


My goal is to get the coordinates of the correlation.
I’m wondering why the highest value of my IFFT is shifted w.r.t to the center of my image_d? I am expecting to have the same coordinates as the center of image_d?

Once i understand this, i am willing to apply the same for my large-scale images as explained above to get the coordinate where the correlation occurs.

any help ?

thanks in advance!

Problem solved: The multiplication kernel is wrong.