Thursday, October 6, 2016

Fourier Information



($Again \, Good \, Job \, Roland \, For \, The \, Title$)

Now now, what have we here?
Fourier Transform! And lots of it...

Do I know what Fourier Transform is?
Yes, it's been discussed in many a physics class for at least three years now.
Yes, I know the equation (For 1D at least)

$\mathcal{F}(k) = \int_{-\infty}^{+\infty} f(x) e^{2\pi ikx} dx$
$Yeahp \, looks \, legit$

Yes, I kinda know what it means. Converts a signal into frequency space, right? $Right?$
How does it actually work? I have no idea. Don't even ask me about DFT or FFT.



Well to hell with the theory (for now). $Import \, FFT \, = \, Problem \, Solved$

The first thing we did was to take the Fourier Transform of a circular aperture.
As an aspiring physicist I know that this should look like an Airy Pattern. Why? $NO \, IDEA$

And lo and behold
That doesn't look right...

Turns out directly converting a matrix to uint8 without normalizing to 255 in Scilab causes much information to be lost.

There we go

That looks cool. Physicists sure get to see cool stuff.
But wait, we also see this in high school Biology!
Where you ask?
Well lenses actually perform Fourier Transform on images.
If you tried adjusting a microscope for yourself this might look familiar.

What is that?


Oh look it's a cute little bacterium
$Or  \, a \, microscopic \, mouse$

Mathematically (computationally?), this is the result of convolving an image with an aperture of different sizes.
Physcially, this can be a result of varying the object distance from the lens.



What else can we use FFT for? Finding stuff!
Technically, multiplying the FT of an image and the conjugate of the FT of another would show a correlation between the two images.
If we see a high correlation then we can say that the two images share the same features.

Now if we limit the second image to a small feature say the letter 'A', then we can find where the letter 'A's are in an image.

Like this




$Magic$

The high correlation areas don't really look obvious but by applying a threshold we can be more certain where a feature is present and where it isn't.

Now suppose we have a movie poster, say The Avengers

Now I want to know if Captain America is in the movie. What would Cap always have? That's right his shield. 


Lets try to find Cap using the same method as 'A' 

Is that bright spot Cap?
$Yeahp  \, there \,  he \, is.$


So we can now find features in our images. What else can we do with FT?
It can also be used for edge detection.
Before, if you ask me how to find edges in a picture, I would say that you have to check each pixel then compare the pixel value to its neighbors'.
Thats the brute force method. Apparently, using convolution in Fourier space does the same.
By convolving an image with a 3x3 'edge' pattern, we are basically finding any 3x3 pixels in the image that resembles the edge pattern.
For this part I convolved a test image with four types of patterns.




I used the same image of Sunken garden extracted from Google Maps that I used in the previous activity.
Using different patterns result in extracted edges that look similar to the pattern
i.e. horizontal pattern detects horizontal edges better and vertical pattern detects vertical edges better. ...
The built-in edge function from SIVP module of Scilab produced similar results to that of the diagonal pattern.
Meanwhile, using a center dot pattern produced the best results.

Here I applied the same method to "microsoft"
The built-in edge from the Windows 10 package yields a very different result.

Taking the edge of microsoft using FT



HAHAHAHAHA. Get it? Get it?
$I'm \, gonna \, die \, alone$

Well this activity was fun. I'm getting quite used to Scilab now.
Still don't know how to define functions properly though.
My working directory looks so disorganized. And I had to write separate codes for each part.

I did not include some test patterns and their FT's in this post. They will be making an appearance in the next activity.

For this activity, I'm gonna give myself a solid 11/10! $Well \, done \, you$

Spongebob makes a return

No comments:

Post a Comment