Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Image Enhancement -Spatial Filtering vs. Frequency Domain Filtering.

Image Enhancement -Spatial Filtering vs.


Frequency Domain Filtering.
Omar Alrammah


Abstract— Filtering in Special Domain and Frequency Domain ( ) ( ) ∑ ∑ ( ) ( )
has wide used in Digital Image Processing. Low-pass filters are
used to smoothing an image, and high-pass filters are used to To generate a 𝑚×𝑛, or n× linear spatial filter requires that we
sharping an image. Using the smoothing filters to take off the specify 𝑚𝑛 mask coefficients. These coefficients are selected
small details, so it thresholding the part of interest in the image. based on what the filter is supposed to do.
Using the sharping filters to edge the image and pass only the Smoothing filters are used for blurring and for noise
high frequencies. The high-pass filter is used widely in face reduction. Blurring is used in preprocessing tasks, such as
detections. This paper examines both the special domain (SD)
removal of small details from an image. Also, it used in
and the frequency domain (FD) filtering by using a low-pass filter
in special domain and frequency domain, and a high-pass filter in bridging of small gaps in lines or curves. Smoothing linear
special domain and frequency domain, then find the Histogram filters can be also used to Noise reduction. The output image
of the filtered images to differ the image intensities. of a smoothing, linear spatial filter is simply the average of the
pixels contained in the neighborhood of the filter mask. One of
the smoothing filters is Gaussian low-pass filter:
I. BACKGROUND AND OBJECTIVE
This project introduces spatial and frequency domain filters. Sharpening or edging is to highlight transitions in intensity.
Therefore, it involves creating masks, performing convolution, While image blurring can be accomplished by pixel averaging,
Fourier transforms and inverse Fourier transforms. Digital sharpening can be achieved by spatial differentiation. The
Image Processing helps in maximizing clarity, sharpness, second derivative would produce a double edge one pixel
smoothing, and details of features of interest. Image thick, separated by zeros. Thus, the second derivative
Enhancement transforms images to provide better enhances fine detail much better than the first derivative, a
representation of the small details. It is a basic tool for property that is ideally suited for sharpening images. The
researchers in a wide variety of fields including medical second derivative in 2D is The Laplacian:
imaging, art studies, forensics and atmospheric sciences. ( ) ( ) ( ) ( )
Histogram gives an estimate of the probability of occurrence ( ) ( )
of intensity. Histogram manipulation can be used for image Frequency domain techniques are based on the
enhancement. An intensity image is a data matrix whose
manipulation of the transform of the image rather than the
values have been scaled to represent intensities. When the
image itself. Frequency domain techniques are suited for
elements of an intensity image are of class unit 8, it has integer
processing the image according to the frequency content. The
values in the range [0, 255]. principle behind the frequency domain methods of image
A spatial filter consists of a neighborhood, typically a small enhancement consists of computing the 2-D DFT.
rectangle, and a predefined operation that is performed on the
manipulating the transform coefficients by an operator filter,
image pixels encompassed by the neighborhood. Filtering
and then performing the inverse transform. The transform of
creates a new pixel with coordinates equal to the coordinates
the image has two components magnitude and phase. The
of the center of the neighborhood, and whose value is the magnitude consists of the frequency content of the image. The
result of the filtering operation. A processed (filtered) image is phase is used to restore the image hack to the spatial domain.
generated as the center of the filter visits each pixel in the Filtering is easier to do in the frequency domain. Therefore,
input image. When performing linear spatial filtering, it is
enhancement of image f(x, y) can be done in the frequency
doing correlation, or convolution in 2D. The correlation:
domain based on DFT. The convolution in spatial domain is
nothing but multiplication in frequency domain.
( ) ( ) ∑ ∑ ( ) ( ) ( ) ( ) ( ) ( )
A Gaussian low-pass filter in frequency domain is used to
The mechanics of convolution are the same, but the filter is
smooth the image and noise reduction, and a Gaussian high-
first rotated by 180°:
pass filter in frequency domain is used to sharp and edge the
image. The Gaussian low-pass filter in Frequency domain:
Image Enhancement -Spatial Filtering vs. Frequency Domain Filtering. 2

And the Gaussian high-pass filters in frequency domain:

There are three basic steps to frequency domain filtering, the


image must be transformed from the spatial domain into the
frequency domain using the Fast Fourier transform, taking
only real values of the resulting complex image, and the
filtered image must be transformed back to the spatial domain.

II. WORK DESCRIPTION


Applying a color image in Matlab to convert it to a gray
scale image and display it. Applying two kinds of filtering,
low-pass, and high-pass filtrations in both spatial domain and
Frequency domain in the gray scale image. Thus, the Matlab Figure 2: Crop gray scale image.
codes have five sections, converting the color image to gray
scale image, and crop it. Applying a spatial domain Gaussian 2- Apply Gaussian low-pass filter in spatial domain
low-pass filter using 15×15 mask with variance =15 by
figure 4 to the gray scale image in figure 2. Figure 3
using LPHS=fspecial('gaussian',15,15), and imfilter(I3,LPHS)
. Then, display the filtered image and its histogram. Applying shows the filtered image is blurred and loose most of
a spatial domain Laplacian of Gaussian high-pass filter using the small details. Notes the filter in 3D in figure 5
15×15 mask with variance σ^2 =2 by using HPHS =
fspecial('log', 15, 2), and imfilter(I3,HPHS). Then, display the
filtered image and its histogram. Applying a frequency domain
shifted Gaussian low-pass filter, and a frequency domain
shifted Gaussian high-pass filter. Meshgrid arrays for
implementing filters in the frequency domain by using [X
Y]=meshgrid(X,Y), thus, multiplying the shifted filter with the
shifted DFT to get the filtered image, By using A = fft2(I3),
and A1=fftshift(A). Then find the histogram of the filtered
images. Using imagesc to Scale data and display image object
in color mapping to see the different in the filtrations. Also,
display the four different filters in 3D to visualize them.

III. RESULT AND DISCUSSIONS Figure 3: Smoothed image by Gaussian low-pass filter in
1- Convert the color image to gray scale image and crop spatial domain.

it. See figure 1 for the original image, and figure 2 for
the crop gray scale image.

Figure 4: Gaussian low-pass filter in spatial domain with 15×15


mask with variance σ^2 =15.

Figure 1: Original Image.

Figure 5: Gaussian low-pass filter in spatial domain in 3D.


Image Enhancement -Spatial Filtering vs. Frequency Domain Filtering. 3

3- Apply Laplacian of Gaussian high-pass filter in spatial


domain figure 6 to the gray scale image in figure 2. .
Figure 5 shows the filtered image is sharped and edged
the image. Notes the filter in 3D in figure 7. It can
detect the Pumpkin, the face boarders clearly.

Figure 8: Blurred image by Gaussian low-pass filter in


frequency domain.

Figure 5: Edged image using Laplacian of Gaussian high-pass


filter in spatial domain

Figure 9: Shifted Gaussian low-pass filter in frequency domain.

Figure 6: Laplacian of Gaussian high-pass filter in spatial


domain with 15×15 mask with variance σ^2 =2.

Figure 10: A 3D shifted Gaussian low-pass filter in


frequency domain.

5- Apply Gaussian high-pass filter in frequency domain


Figure 7: Laplacian of Gaussian high-pass filter in 3D.
in figure 12 to the gray scale image in figure 2. The
4- Apply Gaussian low-pass filter in frequency domain in high-pass filter is equal to 1- the low-pass filter. The
figuer9 to the gray scale image in figure 2. The filter filter has the same size of the gray scale image, which
has the same size of the gray scale image, which is is 705×741. Shifting the filter and shifting the DFT of
705×741. Shifting the filter and shifting the DFT of the gray scale image results of the sharper image in
the gray scale image results of the smoothing image figure 11. It is edged and can detect the shapes in the
infiguer 8. It is blurred and loose most of the small image. It can detect the Pumpkin, the face boarders
details. See the filter in 3D in figure 10. clearly. See the filter in 3D in figure 13.
Image Enhancement -Spatial Filtering vs. Frequency Domain Filtering. 4

Figure 14: The histogram of the low-pass filter in spatial


domain.
Figure 11: sharped image by Gaussian high-pass filter in
frequency domain.

Figure 12: Gaussian high-pass filter in frequency domain.

Figure 15: The histogram of the low-pass filter in frequency


domain.

7- Comparing the histogram of the high-pass filters in


both domains showing in figure 16, 17. Since
manipulating the filter in spatial domain is difficult, it
is hard to get the same intensities, however. Both of
the image intensities have a big value when the image
is black and a small value when the image is white.

Figure 13: A 3D shifted Gaussian high-pass filter in frequency


domain.

6- Comparing the histogram of the low-pass filters in


both domains showing in figure 14, 15. It can be said
that both of the filtered images have almost the same
intensities. In the 150 to the 200 values, they have the
same intensities.

Figure 16: The histogram of the high-pass filter in spatial


domain.
Image Enhancement -Spatial Filtering vs. Frequency Domain Filtering. 5

9- Also, in figures 21, the high-pass filtered images, it


is clear that the boarder in the Pumpkin and the face
is almost the same. See figures 22, 23.

Figure 17: The histogram of the high-pass filter in frequency


domain.

8- Figure 18 shows the comparison between the Figure 21: Comparison between the high-pass filtered
low-pass filtered images, it is clear that they slightly images.

look the same, the color mapping image can explain


more about the similarity as in fingers 19, 20.

Figure 18: Comparison between the low-pass filtered images. Figure 22: Color mapping for the edged image by Gaussian
high-pass filter in spatial domain.

Figure 19: Color mapping for the smoothed image by Gaussian


low-pass filter in spatial domain.

Figure 23: Color mapping for the edged image by Gaussian


high-pass filter in frequency domain.

VI. CONCLUSION
Image enhancement techniques with using Matlab as it is
showed from the results, the both ways for filtering spatial and
frequency domain are more or less the same. When it is
desired to filter an image with a small mask, it would be easier
to use the spatial domain. However, in the frequency domain,
Fourier transformation is more accurate and easier to
Figure 20: Color mapping for the smoothed image by Gaussian manipulate. Spatial filters offer considerably more versatility
low-pass filter in frequency domain. because they can be used also for nonlinear filtering, which we
Image Enhancement -Spatial Filtering vs. Frequency Domain Filtering. 6

cannot do in the frequency domain. If it is needed to blur an


image, a low-pass filter or average filter in both domains
would be the choice to smooth the image. On the other hand,
using high-pass filter is for sharping the image.

REFERENCES

[1] Rafael C. Gonzalez, Richard E. Woods, "Digital Image


Processing", Third Edition, New Jersey, 2008.
[2] Digital Image Processing, Using MATLAB, by Rafael C.
Gonzalez, Richard E. Woods, and Steven L. Eddins.
[3] Image Processing Toolbox, For Use with MATLAB.
[4] Sarah Ali, ‘Image Enhancement -Spatial vs. Frequency
Domain Filters’ Dijlah University College, Technical Report
May 2014.

You might also like