Question

I have written a simple program (in ANSI C) to convolve two real 2D arrays with FFTW (using the r2c and c2r plans). Everything (except my understanding of the scale) works well and the output looks fine.

The problem is that I am a little confused on how to scale the two arrays so after the process IDFT[DFT(A)DFT(B)] (DFT: discrete Fourier transform. I: Inverse.) the scale of the final result is correct. Say image A is a square of width a pixels and the convolution kernel is b pixels. I then create two padded square arrays of width p=a+b and place both my A and B images in them and do the convolution.

Is multiplying all pixels in the final output with 1/p^2 correct? Thanks in advance.

Was it helpful?

Solution

Since you wanted it as an answer :

http://fftw.org/doc/What-FFTW-Really-Computes.html (The web adress is explicit enough, I think).

Generally, I find the doc of FFTW to be quite useful, but it is cluttered with little details that you need to know. For instance, before closing a program, one should call fftw_cleanup() to prevent some memory leaks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top