21 November 2011

Fourier Transforms

This post is going to get fairly technical, but the results are worth it, so please bear with me. I will start off with some technical terms, which you don't need to remember. For the uninitiated, Fourier Transforms are a pretty hairy set of mathematical functions that deal with frequency. In their purest form, they deal with the frequencies inherent in a mathematical function. This is of no use to us though, when dealing with digital data, that can't be described purely with a mathematical function. We need a special type of Fourier Transform, known as the Discrete Fourier Transform. The discrete here refers to the individual pieces of digital data that we are working with. The most common implementation of this, used in computing, is the Fast Fourier Transform, or FFT as I will refer to it from here on.

Still with me?

What exactly does all this fancy maths do then? It will analyse a set of data, and turn it into a set of frequencies. You can then apply an FFT Inverse to this set of frequencies to get back the original piece of music. What use is all that then. Let me give you an example  The application for all of this most people will be familiar with is sound, specifically music. Imagine you have a piece of music, say 10 seconds long, with for example, a base guitar and some cymbals. You then apply an FFT filter to it, which will transform it from the time domain, to the frequency domain. The data you will see after transformation will show some low frequencies, which would be the base guitar, and some high frequencies, which would be the symbols. You could just apply the inverse transform, to take it back from the frequency domain to the time domain, and reconstruct you piece of music, but (and here is the clever bit) you could remove the high frequencies from the transformed data first, before the inverse transform. You would be left with a piece of music where the base guitar was unaffected, but the cymbals would be almost inaudible. Pretty good huh? If you have a graphic equaliser on your stereo, you will be familiar with the kind of effect I am talking about.

Still with me? Well done.

So what does this have to do with geophysics? In two words, plough lines. Ploughing can leave a lot of streaky lines across your nice geophysics plot. Take the image below as an example, fresh from my last blog post. If you look closely, you can see a lot of plough lines, heading ENE-WSW, cluttering up the place like unwanted junk mail. So what can we do about it? If you imagine our piece of music as being one dimensional, with the dimension being time, you can imagine the image below having two dimensions, X and Y. Specifically, the piece of music is in the 'time domain' and the image is in the 'spatial domain', and we can use even more hairy maths on it, a two dimensional FFT. If you imagine the plough lines as waves crossing the image, we can get a specific frequency for it, and remove it, thereby removing the plough lines from the image.

Here are the steps you will need to take to accomplish this, which fortunately does not require you to do any of the maths yourself, and uses free software. You can click on these on the blog to view bigger versions, which you will probably need to do to see what I am talking about.

1) Firstly, you will need to download piece of free image processing software, called GIMP. Lovely name huh? It's actually pretty powerful.

2) Next you will need to download the FFT filter for GIMP, installing it as described for your system.

3) Now open the image you want to work on, and use Filters > Generic > FFT Forward. You will be left with a very strange image, as shown below.

4) The next stage is quite difficult to explain, I will do my best. The image above, which is somewhat zoomed in, shows the frequencies in the transformed image. It is now in the frequency domain. You will see a cross, radiating from the centre of the image. The centre is where the high frequencies are, going to lower frequencies towards the edge. You will need to zoom in to find what you are looking for, which is a pair of lines of higher readings amongst the frequencies. Due to the nature of the filter, you will get this somewhat mirrored effect. This is the hardest part, and may require some trial end error on your part.

5) Once you have found the relevant frequencies, you will need to surround them both with the Free Select Tool (looks like a lasso), which I have done in the image above. Try and enclose as small a space as possible around the frequencies you wish to remove, otherwise your image may suffer for it. You can do one at a time if you wish.

6) Use the Blur Tool (looks like a drop of water), within the selected area. You don't have to worry about going over the edge, as the selection restricts any changes you make to within the selection. Make sure you give it a good going over with the blur tool.

7) Once both areas have been blurred, remove any selections using Select > None.

8) Now we are ready to go back to the spatial domain. Use Filters > Generic > FFT Inverse.

9) You should hopefully now have your geophysics image with most of the plough lines removed. If you haven't, there is always Undo, and you can try again.

10) In some areas where the plough lines did not originally encroach, you may find that the filter has introduced some artefacts, that look like the original plough lines, which isn't very helpful. These areas can be restored by copying and pasting the parts of the original image that you wish to revert to their original state.

Well, here is the resulting image. Open both the original and filtered images and compare them. The effect is quite striking. There are a few small pieces of the ploughing left, but it has mostly been removed.

No comments:

Post a Comment