Gaussian Blur!
by Joe
Hi everyone!
Previously (see Success!) I implemented a method of my own design, but noted a limitation: I needed to either input the approximate eye radius, or have massive computing power to deal with very large accidental lengths. Inspired by a paper that my supervisor sent to me, in which they use a Gaussian blur effect to turn lots of estimates of a point into one estimate. In fact, it is not truly “inspired” by the paper, but more taken from the paper. Exactly.
So Gaussian blur (as far as I can make out) works by convolving the Gaussian function (essentially a single hump) with the image. This smooths out the image.
I have attempted to apply this to my method. But first I need a FFT library. The following are my installation woes:
OpenCV (http://opencv.willowgarage.com/wiki/) and FFTW (http://www.fftw.org/) are C++ libraries. OpenCV is for image processing, and FFTW is used to perform Fourier Fast Transforms. They would be great, and really complement my project. However it turns out that its somewhat impossible to install and use them with any windows program. I have literally wasted days of my life trying to get them to work with either Microsoft Visual C++ 2010 or Netbeans. In the end I gave up.
In the end I gave up.
If anyone knows of any good (simple!) tutorials, could they possibly let me know? I think I will have to build OpenCV from the source code, but I really don’t know how I would go about that. FFTW requires me to use some lib.exe program from Visual C++ to add the libraries. But it seems to crash every time I run it.
In the mean time I am using a C program for FFT I found at http://www.tech.dmu.ac.uk/~eg/tensiometer/fft/. It appears to work… However their are some interesting results when I use it to perform a Guassian Blur.
Here are my Gaussian Blur attempts:
Blurs to:
First thing to note, the FFT program only accepts multiples of 2, so I had to stretch the image into a square frame. Not such a big deal as I can always stretch it back afterwards.
Second thing to note. WTF is it shuffled??? It appears to have been quartered and then shuffled. I can only assume this is a fault with the FFT library, but I wont know until I can test the same method out with a different FFT library.
Third thing to note, the Guassian Blur worked! This is my first program using any FFT’s, so I am very proud of this 🙂
Hey,
I loved your post about FFT. Latest version of OpenCV does provide FFTs, I guess. If you’re looking in Python, you can use SimpleCV.
There’s no problem with the FFT algorithm. Fourier Transform of the image is always taken from it’s center hence it looks like divided in quarters and swapped. You need to do something which is called FFTShift before convolving it with Gaussian Filters(or any other filters). I would suggest you to read up about shifting. It’s not that difficult. And there are couple of algorithms for FFT using OpenCV on the net. You might find them helpful.
If you’re into Image Processing, I would recommend you to read Digital Image Processing by Gonzalez and Woods. It also shows the examples FFT and shifting and various filters in MATLAB. If you have MATLAB, you could try it and compare the output of MATLAB and OpenCV.
Cheers,
Jay
Hi Jay,
Thanks for you reply! I’m glad you enjoyed it.
Ah I see about the FFT taking it from the middle, I will look into the FFTshift.
I’ve just started a summer project at Portsmouth Uni doing some image processing stuff, mainly eye/feature detection, which is why I started the blog. I can see by yours that your very into it, when/if I get OpenCV running I will check it out 🙂
The book looks interesting if I have time I’ll have a look.
I should be getting hold of MATLAB soon!
Thanks again 🙂
Joe