Chapter 3 - Image Enhancement in Frequency Domains
Chapter 3 - Image Enhancement in Frequency Domains
Spatial frequency is measured in cycles per unit distance, often cycles per pixel or
cycles per inch. High spatial frequencies correspond to rapid changes in intensity,
which typically represent fine details, edges, and textures. Low spatial frequencies
correspond to slower changes in intensity, representing overall structures and
smooth regions in the image.
Frequency Domain Filters are used for smoothing and sharpening of image by
removal of high or low frequency components. Sometimes it is possible of removal
of very high and very low frequency. Frequency domain filters are different from
spatial domain filters as it basically focuses on the frequency of the images. It is
basically done for two basic operations i.e., Smoothing and Sharpening.
In spatial domain, we deal with images as it is. The values of the pixels of the
image change with respect to scene. Whereas in frequency domain, we deal with
the rate at which the pixel values are changing in spatial domain.
In frequency domain first transform the image to its frequency distribution. Then
our black box system performs what-ever processing it has to performed, and the
output of the black box in this case is not an image, but a transformation. After
performing inverse transformation, it is converted into an image which is then
viewed in spatial domain.
Transformation:
Transformation in image processing that involves transforming an image from its
spatial domain (pixel values arranged in rows and columns) into its frequency
domain (representation of different spatial frequencies present in the image). This
transformation is typically achieved using a mathematical tool called the Fourier
Transform.
A signal can be converted from time domain into frequency domain using
mathematical operators called transforms.
There are many kind of transformation that does this. Some of them are given
below.
Fourier Series
Fourier transformation
Basic Terminologies:
C=r+jI
Where, r and I are the real number and j is the imaginary number equals to square
root of -1. i.e. j =
j2 = -1
In polar coordinates:
C = |C| (Cosθ+jSinθ)
If ejθ = Cosθ+jSinθ
Then,
C = |C| ejθ
In 1807 Jean Baptiste Joseph Fourier proposed a Fourier function which is the
combination of both sine and cosine functions.
By combining both, we can handle odd and even function of Sine and Cosine
waves. This is also called Sinusoid function.
Fourier series:
Where,
Form calculus
Following graph shows the combination of periodic function of sine and cosine.
This graph at the bottom is sum of above four graphs.
Fourier Transformation:
Fourier transform is the input tool that is used to decompose an image into its Sine
and Cosine components. It deals with non-periodic function with finite area. This
is the integral of weighted Sine and Cosine functions.
1. Fourier Transform
2. Inverse Fourier Transform
Fourier Transform:
1 1
1 -1
1 1 1 1
1 -j -1 J
1 -1 1 -1
1 J -1 -j
F(k) = mask*f(x)
F(k,l) = mask*f(x,y)*maskT
Here,
mask = maskT
F(k,l) = mask*f(x,y)*mask
Example1: Calculate 4-point DFT for 1-D sequence f(x) = {0,1,2,3} using matrix
method.
F(k) = mask*f(x)
* = =
F(m,n) =
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
Solution:
1 1 1 1
1 -j -1 J
1 -1 1 -1
1 j -1 -j
By Lec. Pratik Chand, NCCS Page 9
Image Processing – CSIT 5th Semester
Transpose to mask is
1 1 1 1
1 -j -1 J
1 -1 1 -1
1 j -1 -j
F(k,l) = mask*f(x,y)*maskT
* *
* =
F(k,l) = (1/m*n)(mask*f(x,y)*mask)
Mask =
1 1 1 1
1 J -1 -j
1 -1 1 -1
1 -j -1 J
32 -8 0 -8
-8 0 0 0
0 0 0 0
-8 0 0 0
Now, m = 4, n = 4
= (1/16) * *
= (1/16) *
= (1/16)
Properties of DFT:
There are several properties of Discrete Fourier Transformation some of them are
describe bellow:
1. Separability:
It tells us that we can compute the 2-D transform by separating 2-D function in to
two 1-D function. First compute the 1-D transformation along with each row of the
input image and then compute another 1-D transformation along with each column
of the input image. After that combine both 1-D transformation result to get 2-D
transformation.
( ) ∑ ∑ ( )
∑ ( )
Where,
( ) ∑ ( )
2. Translation:
This property state that multiplication of a function f(x,y) with an exponential in
the spatial domain leads to frequency shift.
( ) = F(u-u0, v-v0 )
And
f(x-x0, y-y0) = ( )
3. Periodicity:
FT and IFT are periodic if M is the period then,
| F(u,v) | = | F(-u,-v) |
4. Rotation:
If the image is rotated by an angle the FT is also rotated by same angle.
5. Distribution:
The FT is distributed over addition
6. Scaling:
Any scaling (changes) in spatial domain is reflected in frequency domain.
a.f(x,y) = a.F(u,v)
And
f(ax, by) = F( )
Filter Parameters:
Distance Function:
In the filter transfer function equations, this distance to the origin is denoted as
D(u,v), or simply as D . Since the frequency domain data ranges from to in
By Lec. Pratik Chand, NCCS Page 15
Image Processing – CSIT 5th Semester
both the horizontal and vertical direction, rather than between ( and ), it is
convenient to use a special function to calculate the distances.
Cutoff Frequency:
The transition point between the pass and stop bands of the filter is known as
cutoff frequency and denoted as D0.
Band Width:
For band-reject and band-pass filters, where the data between lower and upper
cutoff frequencies is either rejected or passed, is called Band Width. The width is
denoted as W.
This filter technique is used to remove high frequency components of the image
and keep low frequency components. Hence it smooth or blur the original image. It
is also used to remove the noise from the image.
distance (D0) from the origin (centered) of the transform. And accept all the low
frequency components.
D(u,v) is the Euclidean distance between center pixel and neighbor pixels
Effect of ILPF
Note: Ringing effect is the rippling (rough), artifact effect in sharp edges.
Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center, where x,y are the coordinate of pixel.
Step3: Compute F(u,v), i.e. the DFT of the image from step 2
Step4: Calculate G(u,v) by multiply F(u,v) by a filter function H(u,v) (i.e. pixel by
pixel multiplication)
Find filter function H(u,v) using Ideal Low Pass Filter with given cutoff
frequency
Step7: Multiply the result from step 6 by (-1)x+y to get origin back to original
position.
Example: Convert the given spatial domain image using Fourier transform and
perform Ideal Low Pass filter to smoothen the image. Choose D0 as 0.5. Show the
step by step procedure.
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
Solution:
Step 1: Multiply (pixel by pixel) the input image by (-1)x+y to move origin to the
center
By Lec. Pratik Chand, NCCS Page 18
Image Processing – CSIT 5th Semester
Step 3: Multiply F(u,v) with the filter function H(u,v) to calculate G(u,v)
Here we are calculating the distance between (u,v) from the center (2,2) of the
mask
(1/16)* * *
Step 5: Multiply (pixel by pixel multiplication) the result by (-1)x+y to move the
origin to its original position
Butterworth low pass filter is very useful in removal of high frequency noise from
the input image. A Butterworth Filter is a type of Active Filter, where the
frequency response of the across its pass band is relatively flat. Because of this
frequency response, Butterworth Filters are also known as Maximally Flat Filters
or Flat-Flat Filters.
By Lec. Pratik Chand, NCCS Page 23
Image Processing – CSIT 5th Semester
Unlike the ILPF, the BLPF transfer function does not have a sharp discontinuity
that gives a clear cutoff between passed and filter frequencies.
Effect of BLPF
Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center, where x,y are the coordinates of image matrix.
Step4: Calculate G(u,v) by multiply F(u,v) by a filter function H(u,v) (i.e. pixel by
pixel multiplication)
Find filter function H(u,v) using Butterworth Low Pass Filter with given
cutoff frequency
Where, n is the order of filter, i.e. 1, 2, 4, 8,… Take any one of these values
Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.
Effect of GLPF:
Smoothing (low pass) filter is useful in many applications. For example, it can be
used to bridge small gaps in broken characters by blurring it.
Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center, where x,y are the coordinates of image matrix.
Step4: Calculate G(u,v) by multiply F(u,v) by a filter function H(u,v) (i.e. pixel by
pixel multiplication)
Find filter function H(u,v) using Gaussian Low Pass Filter with given cutoff
frequency
Where, D2(u,v) = (u-M/2)2 + (v-N/2)2 and M and N are row and column of
input image matrix.
Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.
This filter technique is used to remove low frequency components of the image and
keep high frequency components. Hence, it is sharpening the original image.
IHPF is the simplest high pass filter technique that “cuts off” or rejects all low
frequency components of the DFT that are at a distance less than or equals to a
specified distance (D0) from the origin (centered) of the transform. And accept all
the high frequency components.
Effect of IHPF:
Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center
Step4: Calculate G(u,v) by multiply F(u,v) by a filter function H(u,v) (i.e. pixel by
pixel multiplication)
Find filter function H(u,v) using Ideal High Pass Filter with given cutoff
frequency
Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.
Effect of BHPF:
Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center, where x,y are the coordinates of input image matrix.
Step4: Calculate G(u,v) by multiply F(u,v) by a filter function H(u,v) (i.e. pixel by
pixel multiplication)
By Lec. Pratik Chand, NCCS Page 29
Image Processing – CSIT 5th Semester
Find filter function H(u,v) using Butterworth High Pass Filter with given
cutoff frequency
Where, n is the order of filter, i.e. 1,2,4,8,… chose one of these values
Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.
The transfer function of the GHPF with cutoff frequency at distance D0 from the
center of the frequency rectangle defined as:
Effect of GHPF
No ringing effect
Less edge distortion
Result is smoother then IHPF
Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center, where x,y are the coordinates of input image matrix
Step4: Calculate G(u,v) by multiply F(u,v) by a filter function H(u,v) (i.e. pixel by
pixel multiplication)
Find filter function H(u,v) using Gaussian High Pass Filter with given cutoff
frequency
Where, D2(u,v) = (u-M/2)2 + (v-N/2)2 , M and N are the row and column of
input image matrix.
Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.
H(u,v) = -4 π 2 D2(u,v)
Were, π = 3.14
Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center, where x,y are the coordinates of input image matrix.
Step4: Calculate G(u,v) by multiply F(u,v) by a filter function H(u,v) (i.e. pixel by
pixel multiplication)
Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.
For image of size (1024x1024) pixel requires trillion multiplications and additions
for just one DFT. This would be challenge even for super computers. In another
hand, FFT requires order of 20 million multiplication and addition for same size of
image. This is the significant reduction of computation process.
The separability feature of DFT states that 2-D DFT of f(x,y) can be obtained by
computing the 1-D transform of each row of f(x,y) and then computing 1-D
transform of each column of the result. This is an important simplification because
we have to deal only with one variable at a time. On the basis of this feature we
need to focus only on the FFT of one variable.
F(u) = ∑ ( )
Where, u = 0,1,2………., M-1
W is the twiddle factor used to speed-up the computation of DFT and IDFT
WM = e-j2π/M
And M is assume to be the form of
M = 2n
M=2K
With K being a positive integer, by substitution the values above equation becomes
F(u)= ∑ ( )
We can divides this equation in to two parts even function and odd function
( ) ( )
F(u) = ∑ ( ) +∑ ( )
=
The the above equation becomes
F(u)= ∑ ( ) +∑ ( )
Now, the even and odd function can be define
Feven (u) = ∑ ( )
For u = 0,1,2,3……….,K-1
Fodd (u) = ∑ ( )
For u = 0,1,2,3……….,K-1
Complexity analysis:
Here, points x0, x2, x4 and x6 have been grouped into one category and similarly,
points x1, x3, x5 and x7 has been put into another category.
Now, we can further make them in a group of two and can proceed with the
computation.
Twiddle Factor:
A twiddle factor, in fast Fourier transform (FFT) algorithms, is any of the
trigonometric constant coefficients that are multiplied by the data in the course of
the algorithm. This remains the term's most common meaning, but it may also be
used for any data-independent multiplicative constant in an FFT. It is used to speed
up the operation of DFT and IDFT.
FFT:
FFT is used to change data from spatial domain to frequency domain
Xn -------------- Xk
(Change)
This change means change in occurrence of sequence in spatial domain data.
First divide the given spatial domain data (Xn) into two parts according to Odd and
Even sequence numbers.
Xn -------------- Xk
(Change)
This change means change in occurrence of sequence in frequency domain data.
IFFT:
IFFT is used to change data from frequency domain to spatial domain
In DIT-IFFT sequence of output data in spatial domain (Xn) have order variation.
Xk -------------- Xn
(Change)
This change means change in occurrence of sequence in spatial domain data.
By Lec. Pratik Chand, NCCS Page 41
Image Processing – CSIT 5th Semester
f(x) = {1,2,3,4}.
Solution:
Hence, Xk = {10, -2+2j, -2, -2-2j} this is the DFT of given f(x).
Note:
Complex Conjugate: A conjugate of a complex number is another complex number
which has the same real part as the original complex number and the imaginary
part has the same magnitude but opposite sign. If we multiply a complex number
with its conjugate, we get a real number.
Example 2: Find the Inverse DFT (IDFT) of given function using DIT-IFFT
Here, X0 = 1, X1 = 2, X2 = 3, X3 = 4
Verification of Result:
Here, sum of result is 10, and 1st term of given function is also 10, verified.
Here, N=8,
Here, N=8
Hence, Xn = {1, 2, 4, 8, 16, 32, 64, 128} this is the IDFT of given function.
For most of the image processing purposes it is better to have the signal in the
frequency domain. In others words, a transformation can be described as the
process of mapping the correlated data to no-correlated data. Each pixel in an
image is correlated with its neighbor pixels. The information represented by any
pixel should be predicted by its neighbors because of the fact that they are all
correlated.
Complexity of DCT:
One-Dimensional DCT:
Where, u = 0, 1, 2, 3…..N-1
√
( )
√
{
There are two kinds of DCT coefficients AC and DC. The DC coefficient
corresponds to the value of C (u) when u = 0. In other words, DC coefficient
provides the average value of the sample data. The rest of the coefficients are
called AC coefficients.
Two-Dimensional DCT:
Based on the one dimensional DCT as described above, the two dimensional DCT
can be achieved.
The above equation shows the two dimensional DCT. It is clear from the above
equation that it is derived by multiplying the horizontal one dimensional basis
function with the vertical one dimensional basis function.
Both one and two dimensional DCTs work in similar fashion. One dimensional
DCT is used mainly in sound signals because of its one dimensional nature,
whereas, two dimensional DCT is used in images because of their tow dimensional
nature.
F(k) = Mask*f(x)
4-point mask:
Solution:
7
-4.4604
1
-0.3172
Example 2:
Solution:
F(u,v) = Mask*f(x,y)*MaskT
Mask MaskT
Haar Transformation:
Haar transform is used in image compression. This is efficient to use in both lossy
and lossless image compression techniques.
F(k) = Mask*f(x)
F(k,l) = Mask*f(m,n)*MaskT
Example:
Hadamard Transformation:
The Walsh-Hadamard transform is a non-sinusoidal, orthogonal transform widely
used in signal and image processing. In this transform, the signal is decomposed
into a set of basis functions.
The Walsh-Hamard has a wide application in the field of science and engineering.
These applications include image processing, speech processing, signal and image
compression, power spectrum analysis, spread spectrum analysis etc.
F(k) = Mask*f(x)
H2x2 =
1 1
1 -1
H4x4 =
1 1 1 1
1 -1 1 -1
1 1 -1 -1
1 -1 -1 1
F(x) = {1, 2, 0, 3}
Solution:
F(k) = Mask*f(x)
* =
End of Unit-3