I aim to get the DFT
of an image in OpenCV.
Using dft
function, I\'m able to calculate it, and then paint it by calculating its magnitude (
I'll summarize my comments into an answer.
When one thinks of doing a Fourier transform to work in the inverse domain, the assumption is that doing the inverse transform will return the same function/vector/whatever. In other words, we assume
This is the case with many programs and libraries (e.g. Mathematica, Matlab/octave, Eigen/unsupported/FFT, etc.). However, with many libraries (FFTW, KissFFT, etc.) this is not the case and there tends to be a scale
where s
is usually the number of elements (m
) in the array to the power of something (should be 1 if not scaled in a mismatched fashion in both the transform and the inverse). This is done in order to refrain from iterating over all m
elements multiplying by a scale, which is often not important.
That being said, when looking at the scale in the inverse domain, various libraries that do scale the transforms have the liberty to use different scales for the transform and inverse transform. Common scaling pairs for the transform/inverse include {m^-1
, m
} and {m^-0.5
, m^0.5
}. Therefore, when comparing results from different libraries, we should be prepared to factors of m
(scaled by m^-1
vs. not scaled), m^0.5
(scaled by m^-0.5
vs. not scaled and scaled by m^-1
vs. scaled by m^-0.5
) or even other scales if other scaling factors were used.
Note: This scaling factor is not related to normalizing an array, such that all values are [0,1]
or that the norm of the array is equal to 1.