Enhancing images using Fourier Transform

In the previous blog, I have partly shown some applications of Fourier transform such as edge detection, template matching, etc. Here we show another application which is image enhancement.

The goal here is to enhance images by removing noise or unwanted repetitive signals. Given that these signals repeat on the image, we would know that one way remove them is by looking at the Fourier transform of the image. Removing these unwanted signals is difficult if we do not have basic knowledge on the different Fourier patterns of different simple images.

 

Anamorphism of 2D FT patterns

FT images are said to be anamorphic since the larger the dimension X in real space, the smaller the dimension 1/X in the frequency space. We try to observe this effect on different patterns.

Tall rectangle aperturetall-rect-0-05-0-125tall-rect-0-1-0-25tall-rect-0-2-0-5

Wide rectangle aperture wide-rect-0-05-0-125wide-rect-0-1-0-25wide-rect-0-2-0-5

In 1D, the Fourier transform of a rectangle is a an exponentially decreasing sinusoid (I think it is a sinc function). This means that a rectangle is a combination of an infinite number of sine functions of varying amplitudes. Below shows the magnitude of the FFT of a rectangle taken from Mathuranathan’s blog

rectangule-pulse-magnitude-of-fft-how-to-plot-fft-in-matlab

We expect that this would be the same for a 2D rectangular image only that the exponential decrease happens in both axes. Thus, we expect a peak intensity at the center which the shape similar to that of the original image rotated 90 degrees.

Two dots along x-axisbig-two-circles-r-0-1big-two-circles-r-0-3big-two-circles-r-0-5

In this part, instead of varying the radius of the circles, we vary the distance between them. The FT observe is just an Airy with interference (alternating dark and white bands). This result can be explained observing that the FT image is just a combination of the FT images of an image of 2 dots separated in the x-axis  and that of a circle centered at the origin. —

“Convolution of an image with a dirac delta copies the image into the position of the dirac delta”

 

Rotation property of FT

We now inspect the effect of rotation of the image on its Fourier Transform. This effect is best observed in images composed of parallel lines – sinusoids or gratings. Below shows the FT of sinusoid along the x-axis for different frequencies. At the right side for each image is the intensity profile along the x-axis of the FT image. The frequency values were determined from Nyquist-Shannon sampling theorem

rotate-f2freq-f2rotate-f4freq-f4rotate-f8freq-f8rotate-f16freq-f16

interf-ft-f4-6interf-4-6

We try to rotate the sinusoid by adding angle dependence on the the x and y components. We also combinations of the sine function.

rot-ft-f4

 

eqn7

 

 

 

prod-roof-ft

 

eqn8

 

 

 

Upon rotation by 30 degrees (first image), the FT image is also rotated. The concept here is that the can show which angles is there a repetition or pattern.

 

RE: Convolution theorem

We introduce another important concept that is important in enhancing images. Essentially, to enhance images, we look at the Fourier space and either delete, enhance, suppress frequencies. To determine which frequencies we want to edit, we need to know what patterns they represent in the real space.

Below shows FT’s of many image patterns. Often times, the images on the left are the recurring noise that we want to remove and the images on the right are their FT’s.

2dots

Starting from the FT of 2 dirac deltas, we predict the resulting FT of other patterns.

circ-r0-05circ-r0-15circ-r0-25

Above is a convolution of a circle and 2 dirac deltas. In the FT plane, the resulting FT is just a product of each FT’s. That is,

result_FT = FT(2 dirac deltas) * FT(cirlce) = (vertical lines)*(airy pattern)

sq-s0-05sq-s0-15sq-s0-25

Above is a convolution of a square and two dirac deltas.

result_FT = FT(2 dirac deltas) * FT(square) = (vertical lines)*(exponentially decreasing intensity of multiple squares)

gauss-s0-05gauss-s0-15gauss-s0-25

Above is a convolution of a gaussian and two dirac deltas.

result_FT = FT(2 dirac deltas) * FT(gaussian) = (vertical lines)*(gaussian in freq space)

Below shows how convolution of random points (dirac deltas) with a pattern copies the pattern to the position of the dirac delta points.

random-patt1
vertical pattern

random-patt3
horizontal pattern

random-patt2
box pattern

Below shows the FT of dirac delta points positioned on the x and y axes.

axis-d-2axis-d-10axis-d-15

It shows that different points in the x and y axes produces vertical and horizontal lines in the FT image.

We now apply all the knowledge and principles we learned previously in enhancing the following images: finger print, lunar images, and canvas.

 

Finger Print Ridge Enhancing

I have a prepared scanned image of my finger print shown below. We want to enhance the ridges by suppressing large ink blobs caused by over-pressing the thumb on the paper.

First thing is to convert the image to gray scale levels and plot the intensity of its FT. One observation is that the FT image is symmetric diagonally. Thus, when we want to remove a part of the FT image (say 10×10 matrix) positioned at lower right, then we must also remove the upper left part of the FT image symmetric with respect to the center.

When we take a cross-section of the original image and look at its intensity profile, it would somehow resemble a sine wave but with some ‘ringing’. This ringing is represented in the FT image as frequencies near the ‘main’ frequency of the sine wave without ringing.

fp-origft-image

 

 

 

 

 

 

 

 

 

Below shows how a filter was used to enhance the ridges of the finger print. We suppress most of the very high and very low frequencies (dark parts) and maintain the intensities of the frequencies inside the annulus filter (light parts). Note that the DC component was not removed. After, I put a threshold to differentiate the ridges from the background. (The whole process takes a lot of effort determining the right threshold values!)

fp-enhance1

One way to say that the filtering was successful is that the large blobs in the original image were removed.

 

Lunar Landing Pictures: Line Removal

The previous image enhancement (finger print) was difficult since the noise (large blobs) were does not depict a specific pattern in the FT image. The following image enhancement is rather easy.

Below shows a lunar image with repeating horizontal lines as noise. The goal is to remove these lines. (I think this is a combination of smaller images and were stitched all together to form the complete image).

lunar

Similar with the finger print, we look at its FT image and analyze the source of the noise. We know previously that repeating horizontal lines represent frequencies in the y-axis of the FT image.

Below shows the original image, the filtered FT image, and the enhanced image. By removing the frequencies in the y-axis (except the DC component), the noise was then removed.

lunar-enhance

 

 

Canvas Weave  Modeling and Removal

Next was to enhance a canvas image. The image is shown below. But instead of using the whole image, I just cropped a part of it since memory error insists in Scilab (this works in MatLab but sadly I don’t have one).

canvas
original image
canvas-crop
crop image

The noise in the canvas is more evident in the cropped image. When we view the FT image, we observe high intensity points in various sites. I have created a filter image on PAINT (though not an advisable method) that would remove the high intensity frequencies, noting the symmetry of the points.

fta1

Below is the result upon using the filter. It is evident that the repeating noise was greatly reduced although not removed completely.

final

The colored version is shown below. Upon filtering, I think it is an artifact that the colors are slightly changed (maybe the intensity or color value) which is difficult separate.

enhance-colr.png

Lastly, I tried to invert the filter – the dark parts become white and the light parts become dark. Upon rendering the image, the result was that the noise was the one generated.

inverted

Advertisements

Author: klguial

undergraduate physics student

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s