Enhancing Images in Fourier Space

Before I begin, I'd like to say that I was hoping this activity to be very fun -- but it was fun in a not-so-good way. To put it simply, it was just very long, and a lot had to be done just to finish one part! I'm just glad I'm already writing this one down so that I don't have to think about it and move on to the next 'short' activity.

The activity was split into six parts.

In the first part, we were tasked to take the Fourier transform of: a wide, and tall rectangle, and dots placed symmetrically and asymmetrically with respect to the image center. After doing so, we get Figure 1.

Figure 1: Fourier Transform of tall and wide rectangle, and dots placed symmetrically
and asymmetrically with respect to the image center.

Looking at the figure we see that, as expected, the Fourier transform of either rectangles give out a pattern similar to the diffraction pattern through a single slit, which further was asserted in the previous post that Fourier transform of such image is just how light would behave when it passes through it. I found the Fourier transform of the dots placed symmetrically and asymmetrically odd however, as it didn't suggest any pattern. Rather, it just is observed to be just that. Nonetheless, it showed signs of being sinusoidal, but we would never know until we looked at it from an analytical point of view.

In the second part of the activity, we investigated on the rotation property of the Fourier transform. Before rotating things however, we first looked at the Fourier transform of the following sinusoids:
\begin{align}\label{no_bias} f(x,y)&=\sin(2\pi f_xx) \\ \label{bias} f_\text{bias}(x,y)&=1+f(x,y)=1+\sin(2\pi f_xx)\end{align}
for different \(f_x\). Doing so, we get Figure 2.

Figure 2: Fourier transform of the sinusoids given in (a)-(e) \eqref{no_bias} and (f)-(j) \eqref{bias}.

Notice that taking the Fourier transform of \eqref{no_bias} gives you two dots placed at \(f_x\) equivalent to the frequency of that sinsoid, and that of \eqref{bias} gives you the same two dots but with another dot at \(f_x=0=f_y\). This is expected because the constant in \eqref{bias} could refer to \(\sin(2\pi\cdot0\cdot x)\) or \(\cos(2\pi\cdot0\cdot x)\) and still it gives you the right results - two dots placed at \(f_x\), which in this case is at \(f_x=0\).

With that out of the way, we made rotated sinusoids given by:
\begin{equation}\label{rotate} f(x,y)=\sin(2\pi f(y\cos\theta+x\sin\theta))\end{equation}
with \(\theta\) the angle the rotated sinusoid makes with the positive horizontal. Taking their Fourier transform, we get Figure 3.

Figure 3: Fourier transform of the rotated sinusoid given in \eqref{rotate}.

Notice that like before,  we get two dots however this time when we connect both dots and looked at the angle they made with respect to the positive horizontal, we see it to be perpendicular to that of the original rotated sinusoid. This is more apparent in Figure 3c, where \(\theta=\frac{\pi}{2}\), and the line connecting the dots in its Fourier transform is \(0\).

We then made more sinusoids given by:
\begin{equation} \label{2dwave} f(x,y)=\sin(2\pi fx)\sin(2\pi fy)\end{equation}
and took their Fourier transform. Doing this, we get Figure 4.

Figure 4: Fourier transform of sinusoid given in \eqref{2dwave}. In (a), we used \(f=100\). In (b),
we summed two terms of \eqref{2dwave} with different \(f\), one is \(100\), the other \(200\).

Looking at it, we see four dots instead of two. It still makes sense however since independently, with respect to each axis, there are the usual two dots at the frequency of the sinusoid. Due to symmetry however, the fourth dot was placed. Adding two terms of \eqref{2dwave} with different \(f\) just adds four more dots where the frequency \(f\) of the other sinusoid is, as expected and is seen in Figure 4b.

In the third part of the activity, we were tasked to get the Fourier transform of two shapes placed symmetrically with respect to the image's center while the shapes were changing in dimension. This was done for circle, square, and gaussian. Doing so, we get Figure 5.

Figure 5: Fourier transform of (a)-(e) circles, (f)-(j) squares, and (k)-(o) gaussians with increasing
radius \(r\), width \(w\), and standard deviation \(\sigma\) placed symmetrically with respect
to the center of the image.
Looking at this, we see that as either shape is increasing in size, the Fourier transform appears to become more smaller, like zooming out of a picture. This is because the Fourier transform assumes that whatever in the picture is periodic thus as you increase their dimensions, it is likened to increasing its period thus making the Fourier coefficients become closer to each other.

We were then tasked to convolve two images with each other - one a black image with 10 bright spots, and the other a random image. Doing so, we get Figure 6.

Figure 6: Two matrices, \(\mathsf{A}\) and \(\mathsf{d}\) were convolved with each other
giving (c), where \(\mathsf{d}\) was replicated in all the bright spots in \(\mathsf{A}\).
Looking at the result of their convolution, we find that the random image was replicated in all the bright spots in the random image. This makes sense because it is only in those bright spots that the image has any value - and the result of any convolution looks a little like both of the signals/images that were convolved with each other.

We were then tasked to make an array of evenly spaced spikes/dirac deltas, and take its Fourier transform. Doing this for different spacing, we get Figure 7.

Figure 7: Fourier transform of array of evenly spaced spikes with different spacing \(s\).
Because dirac deltas are only defined where they are located, the Fourier transform of dirac deltas are also dirac deltas. This time however, notice that as distance between each spike is increased, the distance between spikes in its Fourier transform decreases. This is because given dirac deltas separated by distance \(s\), the spacing between dirac deltas in its Fourier transform becomes \(1/s\) [1].

In the fourth part of the activity, we tried filtering pictures of fingerprint using three basic filters -- low-pass, high-pass, and band-pass. Doing so, we get Figure 8.
Figure 8: Fingerprint, its Fourier transform, filter used, filtered Fourier transform, and reconstructed image.
Looking at Figure 8, we see that low-pass filters make you see the image but blurry, high-pass filters make you see dark images but have edges of fingerprint emphasized. If you combine just the right amount of low-pass and high-pass, you can create a band-pass filter that gives you a bright image however have the edges of your fingerprints more emphasized, as seen in Figure 8k.

In the fifth part, we were tasked to filter out the scan lines in a photo. Showing the whole process, we get Figure 9.
Figure 9: Process of filtering out the scan lines in the photo shown in (a)

Looking at Figure 9a, we see vertical scan lines, thus from second part of activity, in Fourier space, this is manifested as horizontal line. Taking its Fourier transform, we get Figure 9b, and indeed see a horizontal line riddled with series of dots. These are what is causing the scan lines to appear. Thus to filter them out, we use the filter in Figure 9c. We do not include the central part of the Fourier transform so that it will not appear dark, but filter out the rest of the horizontal lines. Filtering out we get Figure 9d, from which reconstructing image we get Figure 9e, which has no more scan lines.

We did a similar thing in the last part of the activity, but this time we filter out the outline of a brick wall. The process is shown in Figure 10.

Figue 10: Process of filtering out brick wall outline in graffiti in (a).
Again, because brick wall outline is periodic horizontally and vertically, these manifest as vertical and horizontal lines in Fourier space. So we take them out not including the central part so that when we filter it and reconstruct it as in Figure 10e, we get an image with little to no trace of brick wall outline. If we invert the filter we used to filter out the brick wall, we get the outlines of the brick wall we filtered out as seen Figure 10h.

I just hope I don't have to make such long posts anymore -- it's getting tiring.

Reference:
[1] n. a. . The dirac comb function. (Web). Accessed on 10/07/18 at https://dspillustrations.com/pages/posts/misc/the-dirac-comb-and-its-fourier-transform.html

Comments

Popular posts from this blog

First Post in this Blog

Edge Detection and Image Segmentation

Analyzing Images in Fourier Space