To give an easily imaginable picture of the FT, imagine your favorite food and you want to learn how to cook it. For you to do that, you have to know the recipe. FT is just the thing for you! Think of your food as a signal composed of many sinusoid components which in this case are the ingredients. The FT is a process that will decompose your favorite signal into its recipe. Basically, it answers the question of how much of this component sinusoid with frequency $f$ is in the signal?
In this activity, we explore the properties of the FT process.Note that since we are dealing with digital images, our FFT in this sense refers to the DFT. The DFT is a sampled FT in a particular interval and does not contain all frequencies but only a set of samples sufficient to describe the spatial domain. Images are easily obtainable 2D objects which makes them convenient to use as our object of study to explore the properties of the Fourier Transform.
A. Anamorphic Property of FT of Different 2D Patterns
From the previous posts, we knew that operations in the FT domain have a corresponding linear operation in other domains (time and space) i.e. convolution:multiplication. Now we look into
anamorphism, a property of the the FT domain wherein a large value (be it length) in one axis is small in another axis. To better explain this, it is best to look at the FT's of the following simple patterns. The patterns are generated through Scilab to ensure symmetry.
|
Figure 1. Narrow Rectangle with corresponding FT
|
|
Figure 2. Wide Rectangle with corresponding FT
|
|
Figure 3. Symmetric Dots, d = 0.5 |
|
Figure 4. Symmetric Dots with varying distances, d = 0.3 (top) and d = 0.7 (bottom) and their corresponding Fourier Transforms |
Figures 1-4 exhibit the anamorphic property of FT. The narrow rectangle for example which is long along the y-direction in the spatial domain is short in the frequency domain. This time, the fourier transform is oriented largely along the x-direction. Anamorphism not only refers to the difference in the sizes along the axes in the different domains. Note that Figure 3 and 4 show that as the distance $d$ from the center along the horizontal becomes large, the grating spacing is small! The domains therefore have an inverse relationship with each other. We can also think of the distance in the spatial domain as the frequency of the sinusoid in the fourier plane.
B. Rotation Property of the FT
|
Figure 5. Corrugated Roof with $f = 4$ and its FT
|
This part seems to be the inverse of the previous [finding the FT of the two dots] only that the orientation is now along the y-direction.
As mentioned, the frequency of the sinusoid is proportional to the spacing of the dots in the fourier plane. We can treat the FT of these pairs as a series of interferograms of the signals with varying frequencies \[f = 4,8,16,20\] What if we're only given the signal itself? How do we determine the frequency? Well, what we can do is to take the distance of dot pairs from the central dot which is the brightest and take its average.
|
Figure 6. Corrugated roof with varying frequencies |
Next, I added constant biases as seen in Figure 7. Figure 7a shows the original corrugated roof with $f = 4$ and no bias yet. Fig7b-7e are sinusoids of frequency $f = 4$ but with biases \[ bias = 0.2, 0.4, 0.6, 0.8\] Note that as we increase the value of the bias, the white portion widens and that the number of dots in its corresponding fourier plane decreases. This could be because our viewing window is
biased at a particular portion of the plane, which only allows us to see fewer frequencies.
|
Figure 7. Corrugated roof with added constant biases. |
Figure 8 shows the corrugated roof with an added non-constant bias. The bias is in the form of a sinusoid with a very low frequency. As can be observed, there is now a non-uniformity in the bright and dark regions and that its FT also differs. We can not observe white dots alone but thin elongated regions in its place.
|
Figure 8. Corrugated roof with added non-constant bias.
|
Now we rotate the sinusoid by $\theta = 30^{\circ}$. Note that we have a signal that runs along the x and y. The addition of the rotation term does not in any way affect the intrinsic properties of the signal itself but only rotated its axes. We can see then that the FT of the corrugated roof are dots rotated by the same amount with respect to the x axis.
|
Figure 9. Corrugated Roof rotated by $\theta = 30^{\circ}$ |
On the other hand, Figure 10 is a sum of one sinusoid along the x-direction and another sinusoid along the y-direction. What we got resembles a checkerboard as can be seen below. Since the signal intersects repeatedly in the spatial domain, we expect the same repetitive pattern in the frequecy domain. Thus its FT resembles a
weave pattern which also describes its spatial counterpart.
|
Figure 10. Combination of sinusoids along the x and y direction
|
|
Figure 11. Combined and rotated sinusoids |
Figure 11 shows a combination of sinusoids but at the same time is being rotated by $\theta = 50^{\circ}$. Note that the amplitude and frequency of the wave seem to differ. This could be because one of a sine and the other is cosine. The displayed modulus shows the expected rotated, repetitive pattern and seem to propagated more along the x in contrast to the one in its spatial counterpart which runs more along y. Remember the anamorphic property?
C. Convolution Theorem Redux
In this part of the activity, we will look at the dirac delta and its convolution to some patterns and also their respective FTs.
|
Figure 12. Symmetric Dots and corresponding FT |
Two dots are symmetrically spaced from the center by $d = 0.5\,units$ and its FT was obtained this time. I will no longer discuss this any further since it was done earlier in this activity. What I want to emphasize here then is that we can think of these dots as two dirac deltas located symmetrically from the center and that the following patterns replacing the dots are patterns convolved with the dirac delta themselves.
|
Figure 13. Symmetric Circles with varying radii
|
|
Figure 14. Symmetric Squares with varying widths |
|
Figure 15. Symmetric Gaussian with varying variance values $\sigma$
|
Figures 13-15 show a circle, square and gaussian in place of the dots. For each pattern, an important parameter for each is varied and the behavior of its FT is noted. For example, for the circle we vary the radius $r$; the width $w$ for the square ;and the variance $\sigma^2$ for the gaussian. Note that as we increase the value of each parameter, the size of its counterpart in the fourier plane decreases. This is another display of the inverse property of the fourier pairs. For the FTs of all the patterns: airy pattern for the circles; sinc function for the squares; and gaussian for the gaussian, we will observe the corrugated pattern in Figure 12. This pattern as we know is a sinusoid. For instance, the fourier of a square is a sinusoid.We can therefore say that the resulting FT is actually the FT of the convolution of the dirac delta and the function themselves!
|
Figure 16. Dirac delta simulated as white pixels distributed at random locations convolved with a 3x3 pattern "H" |
Now we simulate 10 dirac deltas in space by scattering ten white dots randomly in space and a 3x3 pattern of "H" is convolved with it. You might already figured out that convolving any pattern with a dirac delta will only give the exact pattern but is located at the exact locations of the dirac. Note that the value of the white pixel is 1 and 0 otherwise. From primary school, we know that multiplying anything with zero gives us zero. So its like we're only multiplying the values on the planes and we're simply getting its product.
|
Figure 17. Dirac Delta with varying spacing |
In Figure 17, we consider the dirac deltas spaced \[ s = 5,10,15,20,25\,pixels\] away to be our signal and here we observe anamorphism. The nearer the diracs in space, the farther they are in the fourier domain. Retaining the dots, the FT of a dirac is then a constant.
D. Fingerprints: Ridge Enhancements
For the remaining parts of the activity, we make use of our knowledge of the properties of the 2D FT and apply it to image correction.
Below shows (a) my right thumb mark (b) its grayscale image and (c) its FT. It can be seen that the ridges of my thumb are not so well-defined. And that's the problem we want to address. From the FT of our original image, we can design a filter to remove the unwanted frequencies
|
Figure 18. Thumb mark |
Common sensically, we know that what a filter does is to stop something from passing through. But still, I would like to emphasize that a filter
never introduces new information. Figure 19 shows the filter I designed to enhance my thumb mark image. What do you think will happen?
|
Figure 19. FT of thumb mark and the designed filter
|
Figure 20 shows the enhanced thumb mark! :)
|
Figure 20. Enhanced thumb mark |
To better appreciate it, we add contrast in the image making dark lines darker and light areas lighter by converting Figure 20 into its binary image counterpart.
|
Figure 21. Binary image for appreciation, threshold value = 0.5 |
E. Lunar Landing Scanned Images
This part seemed to be intimidating at first. To me, I felt like I was thrown off into the deep waters for the first time after teaching me the theory of swimming! I was only given the question and no directions this time. But when I come to think of it, this is how my research with my Ama (Dr. Batac) started. He posted a basic question and I'm answering it now in all the ways I know and I could.
Anyway, back to the problem at hand, we can see horizontal lines and we want to remove them.
|
Figure 22. Lunar crater
|
So we know that the filtering occurs at the fourier domain and thus the next obvious thing is to look at the image at that domain itself (Figure 23b).
|
Figure 23. Grayscale image and FT
|
|
Figure 24.Filtered image |
What we want then is to remove the high frequency-signals but noting that information should still pass to recover the important ones and effectively the enhanced image. This time, my filter consists of vertical and horizontal lines along the axes but the center being kept open as to not lose the info. What we want is to remove the horizontal lines so by anamorphism, if its thick in one dimension, it should be thin at the other domain. Or you could think of the thickness as the degree of filtering.
|
Figure 25. Before and after |
Figure 25 shows the original and the enhanced images which I deliberately placed side-by-side for comparison.
F. Canvas Weave Modeling and Removal
This part was the most challenging for me. I did this part alone for 5 to 7 days. :( The goal is to clean the image such that the weave patterns caused by the texture of the canvas itself is removed.
|
Figure 26. House
|
|
Figure 27. Grayscale of the original image |
|
Figure 28. FT of the original image |
Ironically, the filter that I ended up using is actually a very simple one drawn from very simplistic thinking. It consists of black circles which block the white spots or the peaks in the FT of my image. I retained the center peak which is the DC as to not filter all the information.
|
Figure 29. Filter used |
Now I have my desired result! It now looks like a charcoal or pencil work. The surface looks smooth.
|
Figure 30. Cleaned Image |
To know what information and how much I filtered, I took the complement of my filter and convolved it with the FT. Figure 32 shows the filtered information.
|
Figure 31. Complement of the filter |
|
Figure 32. Filtered information |
As I said earlier, I did this part for so many days I tried so many filters, mostly made manually. The following shows some of my test filters and their corresponding enhanced image; the filter complement; and the lost information. Because I'm a simple kid, my instant intuition is to block the significantly large white portions with shapes that I think would best cover it up. What I did wrong was that, I also removed the central DC which also removed most of the information and thus the dark images in the second row and it is supported by the images in the fourth row of Figure 33.
|
Figure 33. Other filters tested and corresponding cleaned images and filtered information |
Because I realized that mistake, now I tried an approach where I did not block the center by using a Gaussin with different \[\sigma^{2} = 0.1,10,50,100\]They look better don't they especially the last column? But zooming in, because the method is just the inverse of the one I did previously, the result is also just the opposite of it:
This time, too much information passed through the filter! One will realize this if he zooms-in. The enhanced images still contain weave patterns on their surface but to a lesser degree. But because the ratio of the white to black is not very large, we can still recover the image of the house in the images in the fourth row which correspond to the lost information except of course for the first column which actually just recovered the gray image and not much information was lost.
|
Figure 34. Gaussian filters with different variances |
Rating : 10/10 because I was so bothered by the problem I dreamed of this activity for the entire week that I lost sleep.
Acknowledgements:
I want to express my gratitude to the following people:
Nina Zambale for the first part. She was sharing to me how she did things. Made Parts A-B easier! :D
Carlo Solibet because mostly, he's the one I can talk to about these things. :) So I consult him every now and then even with laptop troubles because we have the same laptop we both encountered stacksize error. He was also very patient when I'm becoming sabaw.
Angelo Rillera same with Carlo. I consulted him most especially on the filter-making. Kudos to Gelo for pausing on his blogging to help me debug my code for the filter! Very helpful and patient to those in need! Pagpalain ka.
Patrick Elegado and Micholo Medrana for also helping me debug my code for the filter.
References:
M. Soriano, "Properties and Applications of the 2D Fourier Transform", class manual. (2016)