FFTW with OpenCV

Nov 4, 2008 | Tags: OpenCV | del.icio.us del.icio.us | digg Digg

In Image Processing, we will using FFT operation many times. Unfortunately, OpenCV only came with DFT function. So we need to use a third party FFT library in order to perform FFT operation. FFTW is a good choice. It's very fast and freely available at http://www.fftw.org.

I've made an example on how to perform FFT operation using FFTW in OpenCV. It simply loads an image, compute FFT & IFFT, then display the final result. The resulted image has no difference with the original, as it should.

I've tested it using MinGW compiler on Windows platform but it should compiled in other platforms with slight modification. If you encounter any problem, let me know it.

Related Articles

The Downloads

14 Comments

Benoit on Oct 14, 2008:

Thank you very much.
(works fine under linux,too)

cassel on Oct 31, 2008:

I can't download MinGW.

Nash on Nov 3, 2008:

Here's how to install MinGW:

http://mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite

blindspot on Nov 6, 2008:

Why do you use the 1D FFT interface instead of the 2D? I find your example really misleading. It's not that you can do meaningful things with the transformed image. Can you?

Nash on Nov 8, 2008:

I used the 1D FFT only for example. You can see one of my FFT applications here:

http://www.nashruddin.com/phase-correlation-function-in-opencv.html

Amir Shaker on Dec 14, 2008:

Can you tell me how to include the fftw library in an mfc project with visual studio 2005. thanks in advance.

Nash on Dec 14, 2008:

check this:
http://answers.yahoo.com/question/index?qid=20081122070058AAj9aLA

aparna on Jan 20, 2009:

can any one tell me how to store the database images in an array in opencv

rizn on Sep 13, 2009:

I want to use fft in Visual c++6.0. what are the steps to configure the VC++6.0. I want same result as is of fft2() in matlab.

Nash on Sep 13, 2009:

Sorry I don't have VC++. But I recommend you to use MinGW instead.

Ary on Mar 13, 2010:

Can OpenCV or FFTW do STFT operation ? (STFT= Short Time Fourier Transform)

i can not find good tutorial about STFT in web

thx for your answer

samontab on Nov 24, 2010:

Nice example. Well commented source code and compiles perfectly under Ubuntu (with a couple of changes in the Makefile though)

Although, you said:
"Unfortunately, OpenCV only came with DFT function. So we need to use a third party FFT library in order to perform FFT operation"

That does not make sense to me. FFTW is a library for DFT, the same type of functionality that OpenCV provides. You have a finite number of pixels, therefore you will be using the discrete fourier transform(DFT). The only difference may be the accuracy or speed, not the Discrete part.

Other than that, keep up the good work!, I would love to see more examples of image processing.

Nash on Nov 25, 2010:

Hey samontab, thanks alot for your correction!

whoosh on Mar 9, 2011:

FYI, cvDFT() is an implementation of an FFT algorithm.

Leave a comment

Name (required)
Email (will not be published) (required)
Website

Characters left = 1000