Some images contain unwanted repetitive patterns like lines. Well, this was never a problem for our experts in image processing. These unwanted patterns can be removed by masking or covering the frequencies seen in their Fourier domain.[1] This activity discusses how it can be done.
To know the desired filter mask to remove the repetitive pattern, we must understand first the convolution theorem.[1] For that, what we can do first is to observe the FFT of different repetitive patterns and convolution of some images.
Pair of dots and other pair-figures along the x-axis
First, we were asked to create binary image of two one-pixel-dots symmetric about the center along the x-axis. The FFT of this image as shown below consists of alternate black and white vertical lines.
Binary of two dots symmetric along the x-axis (left) and the FFT of that image (right). |
The dots were replaced by circles of different radius. Just like the FFT of only one circle, as the radius of the circle is increased the pattern observed on its FFT become smaller. In addition, black and white vertical patterns were also observed on their FFTs. As you scroll down, same thing happen for other images like two squares and two Gaussian circles.
Images of two circles of different radius and their corresponding FFTs. |
Images of two squares of different length and their corresponding FFTs. |
Images of two Gaussian circles of different sigma and their corresponding FFTs. |
How about patterns along the y-axis?
What if the figures/patterns were along the y-axis? We could infer that instead of vertical black-and-white patterns, their FFT would have patterns along the horizontal. To confirm our guess, we get the FFTs of images with patterns along the y-axis as shown below.
So, our guess was right! |
Convolution with image having Dirac deltas in random position
Image with dimension of 200x200 pixel containing ten 1’s or white dots placed in random locations was created. The dots will approximate Dirac deltas[1]. Another image of same dimension with any 5x5 pixel pattern on its center was created.
5x5 pattern
|
The two images were convolved and the resulting image is presented below. We can observe that in convolution output image, the pattern took up the Dirac delta positions. This result is just what is expected considering the convolution theorem.
Image of pattern, image with 10 random Dirac delta locations and the convolution output. |
Horizontal and vertical patterns
Horizontal and vertical repetitive patterns were created by making equally spaced 1’s along the x- and/or y-axis. For vertical or horizontal patterns, the FT is shown below. It can be observe that when the image has horizontal patterns, most of the information of its FFT was found along the x=0 axis. While the image with vertical patterns has most of the information of its FFT along the y=0 axis.
Images with vertical (up) and horizontal (down) patterns with their corresponding FFTs. |
For combined vertical and horizontal pattern with different spacing, the FT results to the following. As the spacing is decreased, the spots in the FFT pattern lessens. Or in other way of observing it, as the pattern in the real space decreases, the pattern in the frequency space increases.
Horizontal and vertical lines of different spacing and their corresponding FFTs. |
Lunar landing scanned pictures: Line removal
In some images, we encounter some unwanted lines. We were given an image captured outside our planet described as "Lunar Orbiter image of one of the craters in the far side of the moon". It contains some unpleasant horizontal lines and we would like to remove those. Since we have known where the information of the horizontal lines in the Fourier domain, the mask that should apply will be that could cover it (white line along the vertical). The filtering was illustrated in the figure below.
FFT of the image (left) and masked FTT (right). |
The original and the resulting image are as follows:
How cool was that? Lines was no longer seen on the processed image :) |
Oil on canvas: Weave modelling and removal
We have another test subject seen below - the detail of Frederiksborg, oil on canvas by Dr. Vincent Daria. The image contains weave patterns and we must put some filter mask to remove these unwanted patterns on the painting.
The image was first read as grayscale and the FFT of the image was shown below. Unlike other FFTs, this contain bright dots scattered around with somekind of arrangement.
FFT of the Frederiksborg detail. |
It is known that most of the information about the image was located at the center of its FFT.[2] So we thought of making a mask that will cover most of the FFT leaving only significant portion at the center. The mask will not just cover unnecessary information about the image, but will also be easy to apply to the FFT.
First filter mask (left) and the masked FFT (right). |
However, we are also asked to get the inverse FFT of the filter mask, but it just won't give us anything. So, another filter mask, containing dots that will only cover the bright white dots of the FFT, was used.
Second filter mask (left) and the masked FFT (right). |
The color of the second mask was inverted and when the inverse FFT of it was obtained, the output look something like the weave pattern. Huh, interesting! :)
Inverse FFT of the second mask (left) with its zoomed in version (right). |
The image of the painting in grayscale is shown below.
Now applying the filter masks...
Resulting grayscale image applying the first filter mask (top) and second filter mask (bottom). |
I think it was really a good idea to use the second mask because it resulted to better enhanced image. Both are able to remove the weave pattern but the second was not that blurry compared to the first. Maybe because there been much information lost when the first mask was used.
Hmm.. Recently, I realized that my data has been so dull, they contain no color at all.. Luckily, I have learned to manipulate image colors using Scilab...
TADAH!
Resulting image applying the first filter mask (top) and second filter mask (bottom). |
I really like the result of using the second filter :)
For this activity, I thank Joshua for all the help on debugging my code. For the knowledge on how to use Scilab in managing the color channels of the image, I would like to thank Floyd.
I would give myself a 11/10 for this activity for accomplishing all the goal. A bonus of 1 point for doing the last part in colors.
__________
References
[1] Soriano, M. "Enhancement in the Frequency Domain." AP 186 Laboratory Manual. National Institute of Physics, University of the Philippines, Diliman. 2013.
[2] R. Fisher, et al. Fourier transform. Retrieved from http://homepages.inf.ed.ac.uk/rbf/HIPR2/fourier.htm
No comments:
Post a Comment