FFT - Generating the frequency spectrum of the image

Started by
2 comments, last by aleks_1661 19 years, 3 months ago
Just wondering if someone could help explain how to generate the frequency spectrum of an image. I have looked around and seem to not be able to find many code examples. This is the sort of image I want to achieve: http://cns-alumni.bu.edu/~slehar/fourier/fourier.html#filtering and this is what I am doing now:

	// values is an array of colour values 1 channel 1 byte per pixel

        fftw_real inVals[FFTSIZE*FFTSIZE];
        fftw_complex outVals[FFTSIZE*FFTSIZE];
    
        for ( int y = 0; y < FFTSIZE; y++ )
	{
	    for ( int x = 0; x < FFTSIZE; x++ )
	    {
	        inVals[x + (y * FFTSIZE)] = values[x + (y * FFTSIZE)];
	    }
        }  
 
        // tried this, just seems to process a single dimension
        //  rfftwnd_one_real_to_complex(plan_rc, inVals, (fftw_complex *) inVals);

        // FFT the image 
        rfftwnd_real_to_complex(plan_rc, FFTSIZE*FFTSIZE,
 	     	   inVals, 1, 0,
	           (fftw_complex*)outVals, 1, 0);
			       
outVals just seems to contain 0's the only decent numbers I have had has been from using the rfftwnd_one_real_to_complex line. FFTSIZE is the size of the input image (in this case 16 (16x16)). I think I am doing something wrong. Do i have to use rfftwnd_one_real_to_complex more than once and somehow combine the results? since it seems to process one row of the image only.

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

Advertisement
Maybe you find what you search here:

http://www.student.kuleuven.ac.be/~m0216922/CG/fourier.html
I noticed that you were using FFTW, but the API has changed much since v2 so I can't really help you. Only thing I can think of is that are you using correct plan? Perhaps you should upgrade your FFTW.. :)
I have the current version (3 somethign or other) installed with visual studio, but i was using the version 2 dev pack for Dev-C++. Ill have a try with the newer one.

And thanks for the link, finally an example! should help me loads!

Thanks

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

This topic is closed to new replies.

Advertisement