FFT is the fundamental transform for image processing in the frequency domain. It's a global transform and later, with the development of short time or windowed Fourier transform, which promotes various wavelets.
There is a function (cvDFT) to implement FFT directly in openCV. But you have to pay attention to three things when using it. Firstly, image format, such as the transform between IPL_DEPTH32F, 64F, and 8U (When you show the same image with different formats, you can get different stuff). Secondly, rearrage the quadrants, swap the first and the third, the second and the fourth. Finally, scaling to the image pixel range if you want an image show. Now the codes are as the followings: