We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Shape recognition by FFT convolution
Page Index Toggle Pages: 1
Shape recognition by FFT convolution (Read 887 times)
Shape recognition by FFT convolution
Apr 26th, 2007, 12:06am
 
I'm implementing a system to search an image for occurrences of a smaller image inside it, using 2D FFT convolution, as described here : http://www.dspguide.com/ch24/7.htm and here : http://www.gamedev.net/reference/programming/features/imageproc/page3.asp (near the end)

My sketch : http://www.viz.nu/fft/

In an nutshell, the method is:
1. zero pad the search image and the "to-be-searched" image to a power of 2 (512)
2. In-place 2D DFT of both the images
3. Complex multiply each bin value in 2D.  (searchimage x image)
4. Reverse DFT the result
5. Linear scale and display this result
6. Maximum value of this 2D array should represent the match location

I feel like I have set up the system correctly and none of my code looks suspicious to me.  But the program only correctly finds the search images *some* of the time!  I'm even using the same test images as the second URL above.  But in my system it is not found in the right location.

Well anyway, if anyone happens to have an idea/resource/verbal abuse, your input is greatly appreciated.  I know this is pretty niche-y stuff..

Re: Shape recognition by FFT convolution
Reply #1 - Apr 26th, 2007, 11:07pm
 
For anyone who is interested, I learned a trick for FFTing images.  Image data is non-zero-mean, or in other words, the pixel data falls in [0.0, 1.0] or [0,255], etc.  

For FFTing images, it helps immensely to renormalize the data to zero-mean.  So before FFTing, scale pixel values to [-1.0, 1.0].  This is a key point that was not mentioned in any of the resources I've been reading.

Page Index Toggle Pages: 1