In the previous blog, we saw what is FT and how it can be used practically. In this blog, we’ll take it from there and give more properties like,

Part 1: Big is small?! – Anamorphism

Since the FT space is in inverse dimension of its object, the value of the object in real space has inverse relation to its Fourier counterpart. Meaning what’s wide in the real space is small in the FT space and vice versa.
For example, we learned the FT of circular apertures from the previous blog. If we vary the size of the aperture, this happens.

anamorph1.png

cool.gifWelp! When we increase the radius of the circular aperture, the airy pattern it have for FT (bottom) decreases.

What about other shapes and sizes? Well let’s just see how they are in the Fourier space. Below are some sample shapes and figures we can play around. Let’s see the anamorphism effect with FT  with the following examples.

2dots.png

For the rectangles, we can see the FT is longer on the shorter dimension of the rectangle since it is narrower in real space. As for the two dots, the FT looks like an airy pattern and double slit got a baby. As such, while the distance between two dots increase, the separation of the distance between each lines decreases just like when the distance between two slits are increased.

Another cool property of FT is that it rotates! Watch this…

v2points.png

Image result for so yeah gifIn this image, a sine wave was created with frequency of 5 Hz where each succeeding sine waves are increments of 5 from the previous image. Notice that the FT of these sine waves are two dots equally spaced from the center.
The exact opposite of when we FT two dots, right. Well in retrospect, it should. Remember how we re-create the original image from FT? We perform another FT. Well yeah.

rot2points.png

doge.jpg

Part 2: Convolution REDUX! – Review on convolution

Still remember convolution? Well, just in case you’ve forgotten already we’ll review a bit.

Using MS paint (or MS paint-like application), create two 1×1 pixel dots equally spaced from the center. Take its FFT. Show results. Easy enough? It should look like this, if you’re getting rusty.

Moving on, can you make the dots bigger? Do the same steps. You can use previous codes if you like or make it from scratch. This is just a blog anyway, not a classroom. So just you know what happens here, it should look like these:

Can you make them Gaussian?

Looking good, mate! Now make them two squares

Now that we’re all good here. Let’s try something new.

Create 200 x 200 array of zeros. Now put 10 1-value within this array. Randomizing the process will be easy of you want a new image every time, but manual for now is okay. 😀

///—–xox—–///

If you can’t google it at the moment and want to try it, you can use this code right here

randompoints.PNG

///—–xox—–///

The random 1’s that we scattered acts like Dirac deltas in the 2D space. Remember the equation for convolution from the previous blog? The one from the real space and not the Fourier space, okay. There we can see that it requires us to integrate two functions. For Dirac delta functions, the integration goes like this

\int f(x) \delta (x-x_0) dx = f(x_0)

Now don’t fret too much about the math, it just means that the result of the integration is just the function evaluated at the point directed by the Dirac delta. To demonstrate, let’s run your code. It should looks like this

See? That’s Dirac delta. You just put your thing over the dots. Image result for ggez

Part 3: A-ok! – Enhancing and Filtering Images

Image result for let's play a gameWith all the FT we’ve done. I think we’re prepared for this –

APPLICATION OF FFT.

But how? Put out your thumb. What do you see? If you see your fingerprints then let’s proceed, for those who can’t, go wash your hands you dirty people!

Can you make out an image out of your finger prints? If not, we can digitally enhance the prints anyway! It’s easy, to be honest.

What we need:

  1. Fingerprint image.
  2. SciLab

What to do:

  1. Load fingerprint image in SciLab. fp.JPG
  2. Take the FFT of your fingerprint. Since the values might be overwhelmingly large, show the FFT in log scale.fft_fp.JPG
  3. Can you see the white areas in Fourier space? That’s the signal of the ridges of your fingerprint.  We can make use of CONVOLUTION to enhance the fingerprint! While in Fourier space, delete the other signals by masking them. An annulus can be useful in masking the FT of your fingerprint. Just don’t forget to convolve the mask with the FFT.filter.JPG
  4. After convolving, recreate the fingerprint image. It should come out something like this.enhanced_fp.JPG

Image result for mind blown gif


But were not done yet. We’ve shown that we can enhance patterns by deleting background signals. Let’s do the reverse now. Load this image in SciLab

luna.JPG

We’re gonna remove the those horizontal stitching lines that are remnants from joining multiple images. How, you ask? Using the same method as we did with the fingerprint. However this time, we’ll use a mask where the unwanted signals will be deleted after the convolution. Here’s the FT of the image and a mask we can use.

How do the result look like? Like this. Pretty right?

enhanced_luna.JPG

Lastly. let’s remove the canvass pattern in this painting. painting.jpg

For simplicity, let’s work with the gray values only for now. The FT and the mask used are these ones

Let’s see how the image was removed of the canvass pattern

paintenhanced_paint

And there you have it! Did you appreciate FFT and its extraordinary powers? I hope you did.

Of course, this activity would be a lot harder if not for these awesome people. I’m looking at you Carlo, Louie, Pat and Kuya Roland. Special thanks go to Trix for supporting me all the time while I’m writing the blog.

thanks.gif

For this activity and blog, i’d rate myself 9.9/10 for not being able to do the RGB for the last part. However, I want to upset this by providing an arguably very good result with the pattern clearing in gray. The blog is kind of pedestrian-friendly, too, so plus points for that (please.)

Advertisements