Choosing Real vs Complex 2D FFTs using apple Accelerate framework

帅比萌擦擦* 提交于 2020-01-23 11:41:40

问题


Can anyone advise on the correct FFT to be using (Real or Complex)? I have looked here but still have questions.

I want to do image correlation to identify the location of a sub image within a master image. I understand the basics of FFTs and iFFTs.

The plan:

  1. Perform an FFT on a master image. 512x512
  2. Take complex conjugate of sub image.
  3. Perform an FFT on the sub image. 30x30 but padded with zeros to 512x512
  4. Complex Multiply the two resulting matrixes
  5. Perform iFFT on result
  6. Even though the result should be (mostly) real, take the magnitude of resulting matrix
  7. Look for maximum value which should correspond to maximum correlation.

I am having trouble getting the results that I anticipate.

If I use the real 2d fft (vDSP_fft2dzrip), the result is in a packed format that makes it hard to use a vDSP_zvmul to multiply to two result matrixes.

If I use the complex fft (vDSP_fft2dzip), I fail to get any correlation at all.

The apple examples and most of the audio examples don't do anything with the results of the forward FFT other than do the inverse.

Can anyone help me get started with image correlation? First question...can I use the complex FFT and avoid the packed format?


回答1:


The only difference between a real and complex FFT is that the real FFT can be slightly more efficient by using a clever packing scheme that transforms a 2^n real FFT into a 2^(n-1) complex FFT. The results should be the same in both cases. So I would stick with the complex FFT for simplicity if I were you, at least until you have everything working.

Have you also taken a look at vImageConvolve_ARGB8888? It seems to do what you are trying to do, with a lot less effort :)



来源:https://stackoverflow.com/questions/13889163/choosing-real-vs-complex-2d-ffts-using-apple-accelerate-framework

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!