Activity 5 – Fast Fourier Transforms in Images

In this activity, we started with the Fast Fourier Transform. The Fourier Transform is a mathematical method of transferring data into a form that is a function of frequency. In images, which are functions in space, we Fourier transform to see the image in inverse space (also called spatial frequency). I would like to discuss how the fourier transform works, but this guy (hyperlink here) says it way better than me. All we really need to know is that we can easily imagine space because we live in normal space but there are times where it’s easier to evaluate and manipulate data if it was in the frequency space.

We’ll begin with something easy

A. The Discrete Fourier Transform

The Fourier Transform has the form of an integral over all space. And normally, Fourier transforms are done analytically on functions. But since we can’t teach computers to do that real fast, it had us stomped. Until some guys named Cooley and Tukey found a way to get the fourier transform of a finite dataset, it’s called Discrete Fourier Transform(sometimes Fast Fourier Transform). A lot of signal processing software today have some form of FFT  routines. 

Interestingly, FFTs in synthetic images can act as a lens transformation.

Let’s see what a fourier transform does to some images:

 

 Left: Original Image. Right: FFT image

So we see what I was talking about. This reminds me of lower Physics courses, light through a slit but with also through a lens. Especial;ly the double slit. It looks exactly like what you’d expect with a Yooung’s Double Slit setup.

B. Convolution

Obviously, not all operations in Frequency space is the same in Time space. In the case of the Fourier Transform, if  h= f+g in time is the same as H =F+ G (because FT is linear) but if h = fg in time, H is NOT equal to FG. In the fourier space, multiplying two functions is the equivalent of CONVOLVING (denoted by *) their inverse transforms. 

In other words, if h = f*g then H=FG.

Let’s try this on an object:

vip

because you are one

let’s convolve it with an object, let’s call it an aperture, say a circle

circle

because we already had one

We take their Fourier Transforms (FTs) and multiply them. Then we take the inverse Fourier Transform of the result, which is

vipfftr3

which is basically what happens if you try to look at an image through an aperture in real life. This system is basically a simulation of a pinhole camera. It even got the the loss of intensity right. So basically, convoluting two images might be like viewing one through another.

C. Correlation

There’s another thing we can do while in Frequency space and that is Correlating two  images. Doing it involves multiplying the FTs of the images, taking the conjugate of the second, multiplying the result and taking the inverse transform again.

The result of which is

Left: Image 1, Center: Image 2 and Right: their correlation

See all the bright dots in the correlated image? Well, that’s all the As aren’t they? So correlation shows all the locations of the same patterns in the images? wow.

D. Edge Detection

We already touched on edge detection in Activity 3. This time, we’re not going skip over the edge detection part. In fact, this is all we’re going to do. In the Convolution part of this activity we “saw” the VIP image through an aperture. But what if instead, we saw it though a pattern?  say  like

capture

A vertical stripe pattern.

This pattern should reveal sectyions in the image that follows this pattern of a vertical stripe. Well, it results in

5dvertical

Again flipped, but obviously conforming to the pattern.

Well we see that the image is flipped, but the edges are obvious now. That’s useful. Let’s try it on other patterns

Left: Diagonal            Center: Horizontal           Right: Spot

 So edge must be really good depending on the pattern we use.

I would like to thank everyone who helped me. Carlo Solibet, Roland Romero for help in scilab coding. And Martin Bartolome for his blog. This was a rusj job 7/10.

About Nestor

One day, I thought, hey, I'll be writer. Turned out that writing isn't exactly a science. Now I'm a physics major wasting time trying to write
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment