Properties and Applications of the 2D Fourier Transform

The 2D Fourier Transform is a good concept since it detects frequencies of periodic patterns. Applications of the 2D Fourier transform may range from Ridge Enhancement, Pattern Removal, etc. Some of these applications will be discussed later. First, I will discuss the basic properties of the Fourier transform.

As discussed in the previous blog, when a large image is transformed to Fourier space, it will become smaller and when a small image is transformed to Fourier space, it will become larger. This property is called anamorphism. For the 2D Fourier transform, anamorphism works independently for the x-axis and y-axis. To demonstrate anamorphism, I generated four different types of images: tall rectangle aperture, wide rectangle aperture, two symmetric dots and two symmetric dots with wider separation.

Figure 1. Images generated to demonstrate anamorphism
Figure 1. Images generated to demonstrate anamorphism

For the tall rectangle (Figure 1 top left), we will expect a wide rectangle with a repeating slit pattern on each axis. For the wide rectangle (Figure 1 top right), we will expect a tall rectangle with a repeating slit pattern on each axis also. For the symmetric dots (Figure 1 bottom left), we will expect a sinusoidal pattern similar to that of the corrugated roof. For the symmetric dots with wider spearation (Figure 1 bottom right), we will also expect another sinusoidal pattern but with a smaller wavelength. To check the predictions, we get the Fourier transform of each image:

Figure 2. Fourier transforms of the images in Figure 1
Figure 2. Fourier transforms of the images in Figure 1

As expected, the results match the predicted Fourier transforms. Anamorphism was demonstrated in the two images (Figure 1 top), a taller image will seem small in the Fourier plane and vice versa. For the case of the symmetric dots, as seen in the previous blog, it should be the Fourier transform of a sinsuoidal wave. Since the Fourier transform of anything in the Fourier plane will just return to the space plane, two symmetric dots will result to a sinusoidal pattern. This applies to the second symmetric dots (Figure 1 bottom right). The pattern seemed thinner because the dots now represent a higher frequency thus having a smaller wavelength.  Anamorphism is also observed for the dots. When the dots are closer to the center (smaller gap between them), the sinusoid will have a smaller frequency thus having a wider wavelength and vice versa.

Now we will discuss the rotation property of the Fourier transform. To demonstrate this, I generated four sinusoidal waves of different angle of rotations (0°, 30°, 45°, 90°) as seen in Figure 3.

Figure 3. Images used to demonstrate rotation
Figure 3. Images used to demonstrate rotation

For the rotation property of the Fourier transform, I predict that the transform will also be rotated in the same direction and the same angle as that of the rotation in the image space. To again check the predictions, we get the Fourier transforms of the images:

imagepartbft
Figure 4. Fourier transforms of the images in Figure 3

Again, as expected, the Fourier transforms just rotated in the same direction and angle. It is observable for all images in Figure 4. This happens because in the Fourier space, the dots appear on the axis where the periodic pattern (sinusoid) is observed. If the image is periodic along the x-axis, the dots will appear on the x-axis. When the image is rotated, the axis where the sinusoid resides also rotates. This is why the dots also appear on a rotated axis.

This time, I will discuss another property of the Fourier transform which is the combination so I created a pattern in which two types of sinusoids are present: one in the x-direction and the other in the y-direction as seen in Figure 5. I created four of this pattern with different frequency combinations for each.

Figure 5. Images with two types of sinusoid and with different frequency combinations
Figure 5. Images with two types of sinusoid and with different frequency combinations

The images above are generated by multiplying two sinusoids (one running in the x-direction and the other in the y-direction). Each image above also have different frequency combinations. Since the images above are a product of two sinusoids, the Fourier transform of the product of two functions is the convolution of the individual Fourier transforms of each function. Since the Fourier transform of sinusoidal waves are two dirac delta peaks, the convolution of two dirac delta peaks on two dirac delta peaks will be four dirac delta peaks. The peaks will be located at points with the correct x and y frequency combinations. The frequencies present in Figure 5 will be: 1 Hz in x-axis, 1 Hz in y-axis (top left), 0.5 Hz in x-axis, 0.5 Hz in y-axis (top right), 1 Hz in x-axis, 0.5 Hz in y-axis (bottom left), 0.5 Hz in x-axis, 1 Hz in y-axis (bottom right).

Figure 6. Fourier transforms of the images in Figure 5
Figure 6. Fourier transforms of the images in Figure 5

The expected results were correct and the dots seem to be located on the correct points in the Fourier plane. Also note that the results in Figure 6 are also the convolution of the individual Fourier transforms of the sinusoids with different frequencies. This conforms with my predictions. To tackle further the discussion on rotation, I created a new image with three different type of sinusoidal waves: one along the x-axis, another along the y-axis and the last along an axis rotated 45°. As discussed above, since the Fourier transform of the product of two functions is the convolution of the individual Fourier transforms of each, convolving two dirac delta peaks into two dirac delta peaks into two two more dirac delta peaks should result to eight peaks. The predictions agreed with the results as shown below in Figure 7.

Figure 7. The image generated to demonstrate combinations and rotations (left) and its Fourier transform (right)
Figure 7. The image generated to demonstrate combinations and rotations (left) and its Fourier transform (right)

For the next part, I will show some common patterns observed in many images and discuss how to use Fourier transform to deal with it. I already discussed symmetric dots above and how they have a sinusoid for a Fourier transform. This time, I will discuss symmetric circles, symmetric squares and symmetric Gaussian curves.

part3circ
Figure 8. Symmetric circles with different distance between them (88, 68, 48, 28 units)

Since we have learned about convolution above, we know that these image are just a convolution of a circle and a dirac delta function. The transform of a convolution is just the product of the individual transforms of each function. Also, we know that the transform of a circle is an airy disk pattern and the transform of a dirac delta function is a sinusoid. For the transforms of the images, we should expect an airy disk pattern with a sinusoidal varying intensity. Along the four images, they differ by separation. In a dirac delta function, when the peaks come closer to the center, the wavelength of the sinusoid is larger and vice versa. So here, we expect the same for the circles.

part3circft
Figure 9. Fourier transform of the images in Figure 8

It may not be noticeable but the sinusoids in each image have different frequencies. This agrees with our predicted results. Also, this same pattern will be observed for the symmetric squares and the symmetric Gaussian curves.

part3sqgft
Figure 10. Symmetric squares and its Fourier transform (top) and symmetric Gaussian curves and its Fourier transform (bottom)

Another common pattern observed in many images are dot patterns. It may be random dots or an array of dots. I generated four images: one with a random dot pattern and the three with evenly spaced dots of different spacing between dots.

dotpattern
Figure 11. The dot patterns generated

The Fourier transform of the images on Figure 11 is shown at Figure 12.

dotpatternft
Figure 12. Fourier transform of the images in Figure 11

In the first image (top left), we notice that the Fourier transform of randomly placed dots is also like a pattern of sinusoidal waves joined together. Since there are 10 peaks with a counterpart peak on the opposite side (with respect to the center), there would at least be 10 sinusoids joined together in Figure 12 (top left). For the other three images, peaks are also observed in the Fourier transform. ALso we notice that anamorphism is observable here. As the gap between dots become larger in the space plane, the gaps between dots become smaller in the Fourier plane. This part of this activity is only to be familiar of the common patterns found on certain images and to be able to remove them using filtering.

Since we are done discussing the properties of the Fourier Transform, we now go to its applications. It is important to note that most of the applications that will be discussed here will be dealing with convolution.

The first application will be dealing with ridge enhancement. In images of fingerprints of people, we notice that sometimes, blotches occur and the lines may appear unclear. To get a better image than the raw fingerprint image itself without altering anything, we use filtering to remove unnecessary frequencies.

fingerprint
Figure 13. Image of my own fingerprint

First of all, and the most important part, we will take the Fourier transform of the fingerprint image and take its logarithm (due to high range of values). The resultant image is seen in Figure 14.

fpfft
Figure 14. Fourier transform of the image in Figure 13

We can see that the Fourier transform of my fingerprint shows an image with a bright central point and two unclear rings around it. We know that these points on the ring correspond to a frequency on the image. Since it is difficult to make a filter manually, I automated the creation of the filter and used a threshold value of 0.45. Since I know that the values on the transform range from 0-1 only, everything below 0.45 will be zeroed out and everything above or equal to it will be equal to 1. The generated filter will be shown in Figure 15.

Figure 13. The generated filter with a threshold of 0.45
Figure 15. The generated filter with a threshold of 0.45

By convolving the filter with the transform of the fingerprint, we get an enhanced image shown in Figure 16. Some parts of the blotches seem to disappear and the gaps on the fingerprints are fixed.

fpwithresult
Figure 16. Original fingerprint (left) with the filtered image (right)

Although it may not be very noticeable but the changes are there if you look closely into the image. Also, a better filter may make better results.

Another application to be discussed here is pattern removal. Based on the known knowledge about the Fourier transform, we can already deduce that we can spot patterns using this method. If we can spot the patterns, we can also remove them by filtering. The next image is a photograph captured by the NASA Lunar Orbiter.

hi_res_vertical_lg
Figure 17. Photograph with observed repeating vertical line pattern (captured by the NASA Lunar Orbiter)

First of all, get the Fourier transform of the image in grayscale. I used the logarithm scale again due to the large difference in values. Figure 18 shows the Fourier transform of the image in Figure 17.

moonsft
Figure 18. Fourier transform of the image in Figure 15

I know that the vertical lines are similar to that of the sinusoidal pattern and similar to that of the horizontal lines so I created a filter that can eliminate the peaks on the x- and y-axis. The created filter is shown in Figure 19.

moonfilter
Figure 19. Filter created to eliminated the vertical and horizontal lines in Figure 17

We note that the center of the filter is hollow. It is because the center peak resembles the addition of a bias to the image. It also contains important information on the very small frequencies. The resulting image after convolving the filter and the Fourier transform of the original will image will be shown at Figure 20.

Figure 18. Original image in grayscale (left) and the filtered image (right)
Figure 20. Original image in grayscale (left) and the filtered image (right)

It shows a very significant result in such a way that most of the vertical and horizontal lines disappeared on the second image. To spice things up, I tried doing the Fourier transform with the individual Red, Greed and Blue channels of the image to retain the color. The result can be found in Figure 21.

partergb
Figure 21. RGB version of the images in Figure 20

The last image to be cleaned is an oil painting from the UP Vargas Museum Collection. In this image, we see the canvas weave that look like small dots scattered almost evenly over the image.

OLYMPUS DIGITAL CAMERA
Figure 22. Oil painting with a canvas weave pattern

I converted the image into grayscale and used Fourier transform on it. The resulting image is shown in Figure 23.

sft0
Figure 23. Fourier transform of the image in Figure 22

In Figure 23, we notice that there are white peaks symmetric along the center of the image. Also, we notice that in Figure 22, the canvas weave pattern seem to be similar to that of Figure 11 (top right). To eliminate those dots, we must filter the image in Fourier plane and remove white peaks in Figure 12 (top right). So in figure 23, I created a filter only filtering the noticeable white peaks.

parte_72
Figure 24. Filter used to partially eliminate the pattern in Figure 22

The resultant image is shown in Figure 25. Although, the dots may not be removed completely, the reason for this is that the other peaks blended with the background in the Fourier plane that is why it is unnoticeable.

paintingorigfilt
Figure 25. The original image (left) vs the filtered image (right) in grayscale

Of course, I want to spice things up again so I separated the colored image into its Red, Green and Blue channels. I performed Fourier transform individually for each channel and convoluted with the same filter in Figure 24. I recombined the three channels and got a result shown in Figure 26. The colors now seemed clearer and some dots or some of the canvas weave pattern now disappeared due to the filtering method.

finalimage
Figure 26. RGB version of the images in Figure 25

Also, to view the removed pattern, I inverted the filter (0’s become 1 and 1’s become 0).  The resultant image is shown in Figure 27 and 28

Figure 27. Grayscale image of the removed pattern
Figure 27. Grayscale image of the removed pattern
Figure 28. Colored image of the removed pattern
Figure 28. Colored image of the removed pattern

.The reason why some colors disappeared after filtering the image because as observed in Figure 28, some colors are removed.

Review:

First of all, I would like to thank everyone who helped me in finishing this activity. I would like to thank Ms. Crizia Alcantara and her blog on the same topic. This is where I confirmed and compared my results. I would also like to thank my classmate, Ralph Aguinaldo for helping me think of ways to create the filter. Lastly, I would like to thank Ma’am Jing for guiding me throughout this activity and for confirming my results.

THANK YOU!
THANK YOU!

Next, I would like to express myself. I super enjoyed this activity especially the applications part. I was shocked at first that I can actually perform pattern elimination myself. I never thought that I can do this once in my life. And for performing part E and F with RGB colors, I give myself a 12 out of 10.

12_2

Appendix:

1

2

3

4

5

6

7

8

9

10

Leave a comment