Digital Image Processing
Digital Image Processing
filtering
The Fourier Transform allows us to isolate and process particular image frequencies,
and so perform low-pass and high-pass filtering with a great degree of precision.
Step 1: Load the image using the cv2.imread() function. This function takes in the path to
the image file as an argument and returns the image as a NumPy array.
Step 2: Convert the image to grayscale using the cv2.cvtColor() function. This is optional,
but it is generally easier to work with grayscale images when performing image processing
tasks.
Step 3: Use the cv2.dft() function to compute the discrete Fourier Transform of the image.
This function takes in the image as an argument and returns the Fourier Transform as a
NumPy array.
Step 4: Shift the zero-frequency component of the Fourier Transform to the center of the
array using the numpy.fft.fftshift() function. This step is necessary because the cv2.dft()
function returns the Fourier Transform with the zero-frequency component at the top-left
corner of the array.
Step 5: Compute the magnitude of the Fourier Transform using the numpy.abs() function.
This step is optional, but it is generally easier to visualize the frequency content of an image
by looking at the magnitude of the Fourier Transform rather than the complex values.
Step 6: Scale the magnitude of the Fourier Transform using the cv2.normalize() function.
This step is also optional, but it can be useful for improving the contrast of the resulting
image.
Step 7: Use the cv2.imshow() function to display the magnitude of the Fourier Transform.
import cv2
import numpy as np
The high-pass filter transfer function is evaluated from the low-pass filter transfer function
and it is given as follows:
The Laplacian can be implemented in the frequency domain using the filter transfer function as,
with respect to the centre of the frequency rectangle, using the transfer function is evaluated as
follows:
For an image f(x,y), the Laplacian is evaluated as follows:
The enhanced image evaluated using Laplacian is given as the following equation:
Here, c=-1.
In this section, we discuss frequency domain formulations of the unsharp masking and high-
boost filtering image sharpening techniques.
The unshap masking is defined as follows:
In terms of high-pass filter transfer function, we can write unsharp masking as follows:
HOMOMORPHIC FILTERING
The illumination-reflectance model can be used to develop a frequency domain procedure for
improving the appearance of an image by simultaneous intensity range compression and
contrast enhancement.
Taking the exponential of s(x, y), we have the filtered signal as follows:
The shape of the function can be approximated using a highpass filter transfer function. For
example, using a slightly modified form of the GHPF function yields the homomorphic
function.
Bandpass and Band-reject filters
The bandpass and band-reject filter transfer functions in the frequency domain can be
constructed by combining low-pass and high-pass filter transfer functions.
Furthermore, a bandpass filter transfer function is obtained from a band-reject function in the
same manner that we obtained a high-pass from a low-pass transfer function:
NOTCH FILTERS
Notch filters are the most useful of the selective filters. A notch filter rejects (or passes)
frequencies in a predefined neighbourhood of the frequency rectangle.
Notch reject filter transfer functions are constructed as products of high-pass filter transfer
functions whose centers have been translated to the centers of the notches.