FFT on Images, and The GIMP!

I didn’t know what this “wavelet” processing meant. Yesterday, on a trip to Yelagiri, my friend Hemant was tampering with the wavelets in Pleiades Pixinsight to process his marvellous image of the Eta Carinae nebulosity that he had captured the previous night. He explained that it was just the Fourier transform of the image, treating pixel value as a function of the two (discrete) co-ordinates. He also explained how noise has only high frequencies, so passing the FT of an image through a low-pass filter would eliminate noise and at the same time, blur the image etc.

Today, I decided to do some reading and experimentation with this. So I ran too Google, which faithfully presented to me this wonderful article from one Prof. Brayer in some CS Department in some university – probably part of some course material on computer vision.

With those wonderful examples, I understood the idea, although a bit slowly. So the idea was that all sharp details like edges of images would (like our favourite Dirac Delta function) produce very large frequency components as well, while blur details (like the DC component) produce only very low frequencies. So blurring an image would translate to a compression of its Fourier Transform.

After some hunting, I found out that The GIMP had Fourier Transform plugins. I used the ones found here.

It was straightforward to install. It required fftw and gimptool, which I obtained by executing:

sudo apt-get install fftw3-dev libgimp2.0-dev

on my Debian system.

After installation, as explained in the Wikibook here I found two new options in Filters -> Generic that would do the FFT and Inverse FFT on an image, to produce another image. The advantage with working this way is that GIMP’s amazing image processing flexibility can be applied to the Fourier Transform, to obtain various effects. The gradient tool, the smudge tool and the blur tool proved to be pretty useful.

After reading through some material, I decided to try my hand at re-processing Image of M42 before noise removal by editing the FFT spectrum.an old photograph of M42 that some of us at IITM took with the institute’s telescope and Dr. Suresh Mohan’s Philips ToUcam webcam. The trouble with this particular image was that, for some reason – maybe manufacturing problems – the webcam was producing “periodic” vertical lines in the image – and the nebula was just about as bright as the lines!! I decided that this will be the ideal place to use the FFT, after looking at the example in the GIMP Wikibook.

After much trial, I understood that I should not remove the higher frequencyImage of M42 after noise removal by editing the FFT spectrum. components – because that would only affect the edges, that too negatively. I tried killing the low frequency components as well, but that didn’t do much good either, because it only removed the nebulosity and black background. After some playing around, I realised that I should kill the intermediate frequencies. So I took the smudge and blur tools and blurred out some of the intermediate frequencies on the horizontal frequency axis. After doing the inverse FT I compared the final and initial images to see a whole world of difference! It had worked!!

I’m excited – I finally “understand” what adjusting ‘wavelets’ / wavelet filters mean. As Prasanna told me today in the mess, wavelet filters work exactly like the equalizers in sound systems – now, that’s a very powerful analogy. Immediately, you’ve got the intuitive feel of how to work with wavelets. Thanks Hemant, Prasanna!

Advertisements