Updated
Updated
Subject : DSP
In this report, we explore the use of the Discrete Fourier Transform (DFT) as a
powerful tool for image edge detection. The DFT is a mathematical technique that allows
us to analyze the frequency components of an image. While it is traditionally used in
signal processing and frequency domain analysis, it has also found applications in image
processing. The central idea is to transform an image from the spatial domain to the
frequency domain using the DFT and identify edges based on variations in the spectral
content.
Motivation
Edge detection using the Discrete Fourier Transform (DFT) offers certain
advantages over other techniques, although it may not always be the best choice for
every scenario. Here are some of the advantages of using DFT-based edge detection:
The report is organized as follows: in the following section, we will delve into the
theoretical foundation of the DFT and its relevance to image analysis. Subsequently, we
will discuss the practical implementation of DFT-based edge detection algorithms and
present examples to illustrate their effectiveness. We will also address the trade-offs and
limitations of these methods. Finally, we will conclude by highlighting the significance of
DFT-based image edge detection and its potential impact on various applications.
Through this report, we aim to shed light on the potential benefits of using the
Discrete Fourier Transform for image edge detection, providing researchers, engineers,
and practitioners with valuable insights into a powerful technique for image analysis and
computer vision tasks.
LITERATURE SURVEY
[1] In this paper author aimed to explain the general algorithms used for edge detection. We have used
Sobel algorithm for the implementation of edge detection using DFT.The Sobel operator is simple to
implement and computationally efficient, making it a popular choice for real-time edge detection in
various computer vision and image processing applications. It is part of the broader family of gradient-
based edge detection operators and is often used as a preprocessing step for more complex tasks, such
as object detection, feature extraction, or image segmentation.
[2] In this paper, Sobel edge detection operator and its improved algorithm are first discussed in term of
optimal thresholding. Then based on Genetic Algorithms and improved Sobel operator, a new automatic
threshold algorithm for images processing is proposed. Finally, the edge detection experiments of two
real images are conducted by means of two algorithms. The comparative experiment results show that
the new algorithm of automatic threshold is very effective. The results are also better than the classical
Otsu methods.
[3] In this paper authors explained about feature extraction by Fourier transform method which is found
to be fundamental essence in our project. Feature extraction using the Discrete Fourier Transform (DFT)
involves analyzing the frequency domain characteristics of signals or images to extract meaningful
information or features. The DFT is particularly useful for capturing frequency-related attributes in data.
[4] In this paper the procedure of reconstructing the suppressed edges are well taken care.In edge
detection, the suppression of edges can occur due to various reasons, including the application of filters
or thresholding. To reconstruct suppressed edges, post-processing techniques are employed. These
techniques often involve signal interpolation, such as using spline or polynomial functions, to
approximate the original edge shape. Additionally, morphological operations like dilation can help
recover some lost edge information by expanding the detected edge regions. Advanced algorithms, like
the Hysteresis thresholding in the Canny edge detector, are used to refine and reconnect fragmented
edges. The goal is to enhance the accuracy and continuity of edge information in the final output,
making it more suitable for subsequent image analysis tasks.
Methodology:
Formulas used:
Procedure:
Start by loading the input image, which is typically a grayscale image. We can use a library like
OpenCV to read the image file.
Preprocessing:
Convert the loaded image to grayscale. Grayscale images are simpler to work with for edge
detection because they have a single intensity channel.
The next step is to apply the DFT to the grayscale image. The DFT is applied to the image pixel by
pixel to transform it from the spatial domain to the frequency domain.
For a 2D image, you will apply the DFT separately to the rows and columns of the image. This means you
perform a 1D DFT on each row and a 1D DFT on each column, or equivalently, a 2D DFT on the entire
image.
The result of the DFT is a complex matrix representing the frequency components of the image.
This matrix has real and imaginary parts, where each element corresponds to a specific frequency
component.
Shifting the DFT Output:
To make it easier to interpret the DFT result, typically shift the zero frequency component to the
center of the matrix. This is done using the np.fft.fftshift function. Shifting allows you to view the low-
frequency components in the center and the high-frequency components at the corners of the image.
import numpy as np
Magnitude Spectrum:
To visualize the frequency components effectively, calculate the magnitude spectrum. This is
done by calculating the magnitude of the complex DFT result. The magnitude spectrum represents the
amplitude of the frequency components in the image.
Creation of visualizations of the DFT output and magnitude spectrum, which will help us
understanding the frequency content of the image.
Edge Detection and Filtering:
Filters in image processing are just what the name suggests, Filter. They are typically a mask
array of the same size as the original image which when superimposed on the ordinal image, extracts
only the attributes that we are interested in. As mentioned earlier, in an DFT transformed image, low
frequencies are found in the center and high frequencies are scattered around, we can then create a
mask array which has a circle of zeros in the center and rest all ones. Now when this mask is applied to
the original image, the resultant image would only have high frequencies. This becomes quite useful as
low frequencies correspond to edges in spatial domain.
After the DFT analysis, perform edge detection using techniques like the Sobel operator. The
high-frequency components in the DFT result often correspond to edges in the spatial domain. By
filtering or enhancing these components, you can detect edges effectively.
Sobel algorithm : The Sobel operator is widely used in image processing, particularly within edge
detection algorithms. Technically, it is a discrete differentiation operator, computing an approximation
of the gradient of the image intensity function. At each point in the image, the result of the Sobel
operator is either the corresponding gradient vector or the norm of this vector. Sobel operator is the
partial derivative of f (x, y) as the central computing 3x3 neighbourhood at x, y direction. In order to
suppress noise, a certain weight is correspondingly increased on the centre point, and its digital gradient
approximation equations
import cv2
from matplotlib import pyplot as plt
import numpy as np
m = -1
for i in range (len( img_back )):
x = img_back [ i ]
for j in range (len( x )):
m = max( img_back [ i ] [ j ] , m)
img_back = m - img_back
fig= plt.figure(figsize=(12,12))
ax1 = fig.add_subplot(2,2,1)
ax1.imshow ( img , cmap='gray')
ax1.title.set_text('Inpu Image')
ax2 = fig.add_subplot(2,2,2)
ax2.imshow(magnitude_spectrum , cmap='gray')
ax2.title.set_text('FT ofimage')
ax3 = fig.add_subplot(2,2,3)
ax3.imshow(fshift_mask_mag , cmap='gray')
ax3.title.set_text('FT + ask')
ax4 = fig.add_subplot(2,2,4)
ax4.imshow(img_back , cmap='gray')
ax4.title.set_text('After inverse FFT')
plt.show ( )
Ringing artifacts:
Ringing artifacts in digital image processing result from spurious signals near sharp transitions in
the input signal. In the FED procedure, they are primarily caused by unnatural suppression of low-
frequency waveforms during Butterworth high-pass filtering. To mitigate these artifacts, a ratio
threshold (γ) is used to eliminate minor lobes, typically containing noise, given their energy is usually
15% to 20% of the main lobe's energy.
Inverse DFT:
Once you've enhanced or filtered the DFT result to highlight edges, you can apply the inverse
DFT to convert the frequency domain representation back to the spatial domain. This will result in an
image where the edges are emphasized.
Software used:
Python
Modules used:
Numpy
Matplotlib
openCv
References:
[1] “A Descriptive Algorithm for Sobel Image Edge Detection” by O. R. Vincent,Clausthal University of
Technology, Germany and University of Agriculture, Abeokuta, Nigeria and O. Folorunso
Department of Computer Science, University of Agriculture, Abeokuta, Nigeria.
https://proceedings.informingscience.org/InSITE2009/InSITE09p097-107Vincent613.pdf
[2] “Edge detection of images based on improved Sobel operator and genetic algorithms” by Zhang Jin-
Yu Chen Yan Huang Xian-Xiang
https://ieeexplore.ieee.org/document/5054605
[3] “DFT domain Feature Extraction using Edge-based Scale Normalization for Enhanced Face
Recognition” by K Manikantan1, S Ramachandran
https://www.sciencepubco.com/index.php/jacst/article/download/212/207
[4] “A New Edge Detection Algorithm Using FFT Procedure” by Tongfeng Yang
https://www.researchgate.net/scientific-contributions/Jun-Ma-2098951355