0% found this document useful (0 votes)
43 views57 pages

Chapter 3 - Image Enhancement in Frequency Domains

The document discusses image enhancement in the frequency domain, focusing on the concept of spatial frequency, which describes how rapidly the intensity of an image changes. It explains the use of frequency domain filters for smoothing and sharpening images by manipulating high and low frequency components, and details the Fourier Transform as a mathematical tool for transforming images between spatial and frequency domains. Additionally, it outlines various filter types, their parameters, and the procedures for implementing an Ideal Low Pass Filter.

Uploaded by

diwashw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views57 pages

Chapter 3 - Image Enhancement in Frequency Domains

The document discusses image enhancement in the frequency domain, focusing on the concept of spatial frequency, which describes how rapidly the intensity of an image changes. It explains the use of frequency domain filters for smoothing and sharpening images by manipulating high and low frequency components, and details the Fourier Transform as a mathematical tool for transforming images between spatial and frequency domains. Additionally, it outlines various filter types, their parameters, and the procedures for implementing an Ideal Low Pass Filter.

Uploaded by

diwashw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Image Processing – CSIT 5th Semester

Unit-3: Image Enhancement in Frequency Domain

Concept of Frequency of an Image:


In image processing, the term "frequency of an image" typically refers to the
spatial frequency content present within the image. Spatial frequency describes
how rapidly the intensity of an image changes across its spatial dimensions, usually
the horizontal and vertical axes. This concept is closely related to patterns,
textures, edges, and other features within the image.

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.

There are two main types of spatial frequency components in an image:

 Low-frequency components: These correspond to slow variations in


intensity and represent the overall structure of an image. They include
smooth regions and large-scale features.
 High-frequency components: These correspond to rapid variations in
intensity and represent fine details, edges, textures, and other small-scale
features.

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.

By Lec. Pratik Chand, NCCS Page 1


Image Processing – CSIT 5th Semester

In spatial domain process is done with following steps

In simple spatial domain, we directly deal with the image matrix.

In frequency domain process is done with following steps

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.

By Lec. Pratik Chand, NCCS Page 2


Image Processing – CSIT 5th Semester

There are many kind of transformation that does this. Some of them are given
below.

 Fourier Series
 Fourier transformation

Basic Terminologies:

Complex number C is defined as:

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θ

By Lec. Pratik Chand, NCCS Page 3


Image Processing – CSIT 5th Semester

Some properties of sine and cosine frequencies:

Fig a: Even Function (Cos) Fig b: Odd Function (Sine)

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:

It represents any periodic function as weighted combination of Sine and Cosine


called Sinusoidal functions of different frequencies. It's a way to decompose a
complex waveform into simpler, fundamental components.

By Lec. Pratik Chand, NCCS Page 4


Image Processing – CSIT 5th Semester

A function f(t) of a continuous variable t, that is periodic with period T, can be


express as the sum of Sine and Cosine multiplied by appropriate coefficients.

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.

By Lec. Pratik Chand, NCCS Page 5


Image Processing – CSIT 5th Semester

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.

Functions (signals) can be completely reconstructed from the Fourier domain


without losing any information.

For this Fourier proposed two methods

1. Fourier Transform
2. Inverse Fourier Transform

Fourier Transform:

1-D Continuous Fourier transform Function is defined by the expression

1-D Inverse Continuous Fourier transform Function is defined by the expression

By Lec. Pratik Chand, NCCS Page 6


Image Processing – CSIT 5th Semester

1-D Discrete Fourier Transform (DFT) Function is defined by the expression

Where, N is number of values, k = 0,1,2…..N-1

1-D Inverse Discrete Fourier Transform (IDFT) Function is defined by the


expression

2-D Continuous Fourier Transform Function is defined by the expression

Where, u and v are frequencies along x and y axis respectively.

2-D Inverse Continuous Fourier Transform Function is defined by the


expression

2-D Fourier Discrete Transform (DFT) Function is defined by the expression

p = 0….. (M-1), q = 0….. (N-1)

Where, p and q are the frequencies along with m and n respectively

By Lec. Pratik Chand, NCCS Page 7


Image Processing – CSIT 5th Semester

2-D Inverse Discrete Fourier Transform (IDFT) Function is defined by the


expression

m = 0…. (M-1), n = 0….. (N-1)

The Mask or Kernel of 2-D DFT:


The kernel or mask of 2-point DFT is:

1 1
1 -1

The kernel or mask of 4-point DFT is:

1 1 1 1
1 -j -1 J
1 -1 1 -1
1 J -1 -j

Formulas of Calculation of DFT:


For 1-D DFT:

F(k) = mask*f(x)

For 2-D DFT:

F(k,l) = mask*f(x,y)*maskT

Where, maskT is transpose of mask

By Lec. Pratik Chand, NCCS Page 8


Image Processing – CSIT 5th Semester

Here,

mask = maskT

So, we can also write

F(k,l) = mask*f(x,y)*mask

Note: square of imaginary number is equals to -1. i.e. j2 = -1

Example1: Calculate 4-point DFT for 1-D sequence f(x) = {0,1,2,3} using matrix
method.

F(k) = mask*f(x)

* = =

Hence, F(k) for 1-D DFT = {6, -2+2j, -2, -2-2j}

Example2: Compute 2-D DFT of the Gray-scale image given bellow:

F(m,n) =

1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1

Solution:

Mask for 4-point DFT is

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

New, F(k) for 2D DFT is

F(k,l) = mask*f(x,y)*maskT

* *

* =

Hence, 2-D DFT of given Gray-scale image is:

By Lec. Pratik Chand, NCCS Page 10


Image Processing – CSIT 5th Semester

For 2-D 4-point Inverse Discrete Fourier Transform (IDFT):

F(k,l) = (1/m*n) (mask*f(x,y)*maskT)

Where, m = number of rows, n = number of column

Here, mask = maskT

So we can also write,

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

Example: Find 2D – IDFT of image

32 -8 0 -8
-8 0 0 0
0 0 0 0
-8 0 0 0

Now, m = 4, n = 4

F(k,l) = (1/16) (mask*f(x,y)*mask)

= (1/16) * *

By Lec. Pratik Chand, NCCS Page 11


Image Processing – CSIT 5th Semester

= (1/16) *

= (1/16)

Hence, 2-D IDFT of given image is

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.

By Lec. Pratik Chand, NCCS Page 12


Image Processing – CSIT 5th Semester

The 2-D DFT can expressed in separate form as:

( ) ∑ ∑ ( )

∑ ( )

Where,

( ) ∑ ( )

For u, v = 0, 1, 2,……. M-1

There are two steps to perform this operation:

1. Perform 1-D transform on each row of image f(x,y) to get F(x,v)


2. Perform 1-D transform on each column of F(x,v) to get F(u,v)

2. Translation:
This property state that multiplication of a function f(x,y) with an exponential in
the spatial domain leads to frequency shift.

Mathematically, if you shift an image in the spatial domain by (x, y) pixels, it


results in a phase shift in the DFT coefficients and vice-versa.

By Lec. Pratik Chand, NCCS Page 13


Image Processing – CSIT 5th Semester

( ) = 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+m, v) = F(u, v+m) = F(u+m, v+m)

If f(x,y) is the real, then

FT shows the conjugate symmetry as:

F(u,v) = | F(u,v) | = | F(-u,-v) | F*(-u,-v)

| F(u,v) | = | F(-u,-v) |

4. Rotation:
If the image is rotated by an angle the FT is also rotated by same angle.

F(r, θ+θ0) = F(R, Φ+ θ0)

5. Distribution:
The FT is distributed over addition

F[f1 (x,y) + f2 (x,y)] = F[f1 (x,y)] + F[f2 (x,y)]

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( )

By Lec. Pratik Chand, NCCS Page 14


Image Processing – CSIT 5th Semester

Frequency Domain Filter:


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.

The convolution is used to evaluate filters in the spatial domain, filtering is


implemented in the frequency domain by multiplication. The image in the
frequency domain is multiplied by the filter’s frequency response in the frequency
domain. Thus, the filter transfer function is simply a matrix of the same size as the
image. The complex values of the image in the frequency domain are simply
multiplied element by element with the filter transfer function to amplify or
attenuate specific frequencies of the image. The inverse Fourier transform is then
used to generate the output image.

Filter Parameters:

Distance Function:

To generate filter transfer functions, it is necessary to know the distance of each


element of the transfer function to the origin (0,0).

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.

Here, fL and fu are lower and upper cutoff frequency respectively.

Smoothing Frequency Domain Filter (Lowpass filter):

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.

Following techniques are used for this filter process:

 Ideal Low Pass Filter


 Butterworth Low Pass Filter
 Gaussian Low Pass Filter

Ideal Low Pass Filter:


ILPF is the simplest low pass filter technique that “cuts off” or reject all high
frequency components of the DFT that are at a distance greater than a specified

By Lec. Pratik Chand, NCCS Page 16


Image Processing – CSIT 5th Semester

distance (D0) from the origin (centered) of the transform. And accept all the low
frequency components.

The transform function of this filter is:

M = no. of rows, N= no. of columns of the matrix

D(u,v) is the Euclidean distance between center pixel and neighbor pixels

Effect of ILPF

 Blurring effect is decrease with increasing cutoff of high frequency (D0)


 Ringing effect is increase (become finer) with increase cutoff of high
frequency (D0)

Note: Ringing effect is the rippling (rough), artifact effect in sharp edges.

Procedure for ILPF

Step1: Read an image


By Lec. Pratik Chand, NCCS Page 17
Image Processing – CSIT 5th Semester

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)

G(u,v) = F(u,v)* H(u,v) (pixel by pixel multiplication)

 Find filter function H(u,v) using Ideal Low Pass Filter with given cutoff
frequency

Step5: Compute the IDFT of the result from step 4

Step6: Obtain the real part of the result from step 5

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 2: Compute the DFT of the image from step 1

F(u,v) = Mask*F(x,y)*MaskT (Matrix multiplication)

Use 4-point DFT filter mask

Step 3: Multiply F(u,v) with the filter function H(u,v) to calculate G(u,v)

i.e. G(u,v) = F(u,v)*H(u,v) (pixel by pixel multiplication)

First find H(u,v) for Ideal Low Pass filter

By Lec. Pratik Chand, NCCS Page 19


Image Processing – CSIT 5th Semester

Given matrix is 4x4 so M/2 = 4/2 = 2 and N/2 = 4/2 = 2.

Here we are calculating the distance between (u,v) from the center (2,2) of the
mask

By Lec. Pratik Chand, NCCS Page 20


Image Processing – CSIT 5th Semester

By Lec. Pratik Chand, NCCS Page 21


Image Processing – CSIT 5th Semester

Here, F(u,v)*H(u,v) is the direct pixel by pixel multiplication

Step 4: Compute the IDFT of the result from step 3

F(u,v) = (1/m*n) (mask*f(x,y)*maskT) (Matrix multiplication)

(1/16)* * *

By Lec. Pratik Chand, NCCS Page 22


Image Processing – CSIT 5th Semester

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:

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.

BLPF with frequency D0 is defined by

Where, n is order of filter

Effect of BLPF

 If n increases, increase ringing effect


 If n is 1, it produce no ringing effect

 The magnitude response is nearly constant (equals to 1) at lower


frequencies.
 There are no ringing effect in pass-band and stop-band

By Lec. Pratik Chand, NCCS Page 24


Image Processing – CSIT 5th Semester

Procedure for BLPF

Step1: Read an image

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.

Step3: Compute F(u,v), 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)

G(u,v) = F(u,v)* H(u,v) (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

Step5: Compute the IDFT of the result from step 4

Step6: Obtain the real part of the result from step 5

Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.

Gaussian Low Pass Filter:


Unlike ILPF, the GLPF transfer function does not have a sharp transition that
establishes a clear cutoff between passed and filtered frequencies. Instead, GLPF
has a smooth transition between low and high frequencies.

GLPF with frequency D0 is defined as:

By Lec. Pratik Chand, NCCS Page 25


Image Processing – CSIT 5th Semester

Effect of GLPF:

 Smooth transition in blurring with increasing cutoff frequency


 No ringing effect

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.

Procedure for GLPF


Step1: Read an image

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.

Step3: Compute F(u,v), 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)

G(u,v) = F(u,v)* H(u,v) (pixel by pixel multiplication)

 Find filter function H(u,v) using Gaussian Low Pass Filter with given cutoff
frequency

By Lec. Pratik Chand, NCCS Page 26


Image Processing – CSIT 5th Semester

Where, D2(u,v) = (u-M/2)2 + (v-N/2)2 and M and N are row and column of
input image matrix.

Step5: Compute the IDFT of the result from step 4

Step6: Obtain the real part of the result from step 5

Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.

Sharpening Frequency Domain Filter (Highpass filter):

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.

We can get high pass by subtracting low pass by 1.

Following techniques are used for this filter process:

 Ideal High Pass Filter


 Butterworth High Pass Filter
 Gaussian High Pass Filter

Ideal High Pass Filter:

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.

By Lec. Pratik Chand, NCCS Page 27


Image Processing – CSIT 5th Semester

The transform function of this filter is:

Effect of IHPF:

 Ringing effect is increase with cutoff frequency (D0) increases


 Edge distortion (Thickness of object boundary) is decrease with cutoff
frequency (D0) increases

Procedure for IHPF

Step1: Read an image

Step2: Multiply (pixel by pixel multiplication) the input image by (-1)x+y to move
origin to the center

Step3: Compute F(u,v), 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)

G(u,v) = F(u,v)* H(u,v) (pixel by pixel multiplication)

 Find filter function H(u,v) using Ideal High Pass Filter with given cutoff
frequency

By Lec. Pratik Chand, NCCS Page 28


Image Processing – CSIT 5th Semester

Step5: Compute the IDFT of the result from step 4

Step6: Obtain the real part of the result from step 5

Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.

Butterworth High Pass Filter:

BHPF with frequency D0 is defined by

Where, n is order of filter

Effect of BHPF:

 If n increases, the filter become shaper and increase ringing effect


 If n is 1, it produce no ringing effect

Procedure for BHPF


Step1: Read an image

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.

Step3: Compute F(u,v), 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)
By Lec. Pratik Chand, NCCS Page 29
Image Processing – CSIT 5th Semester

G(u,v) = F(u,v)* H(u,v) (pixel by pixel multiplication)

 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

Step5: Compute the IDFT of the result from step 4

Step6: Obtain the real part of the result from step 5

Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.

Gaussian High Pass Filter:

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

Procedure for GHPF

Step1: Read an image

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

By Lec. Pratik Chand, NCCS Page 30


Image Processing – CSIT 5th Semester

Step3: Compute F(u,v), 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)

G(u,v) = F(u,v)* H(u,v) (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.

Step5: Compute the IDFT of the result from step 4

Step6: Obtain the real part of the result from step 5

Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.

Laplacian Filter in Frequency Domain


The Laplacian can be implemented in frequency domain by using the filter shift to
the center.

H(u,v) = -4π2 [u2 + v2]

If center is shifted at P/2 and Q/2

H(u,v) = -4 π 2 [(u-P/2)2 + (v-Q/2)2]

Where, P and Q are order of matrix

H(u,v) = -4 π 2 D2(u,v)

Were, π = 3.14

By Lec. Pratik Chand, NCCS Page 31


Image Processing – CSIT 5th Semester

Procedure for GHPF

Step1: Read an image

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.

Step3: Compute F(u,v), 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)

G(u,v) = F(u,v)* H(u,v) (pixel by pixel multiplication)

 Find filter function H(u,v) using Laplacian Filter in frequency domain


H(u,v) = -4 π 2 D2(u,v)
Where, π = 3.14

Step5: Compute the IDFT of the result from step 4

Step6: Obtain the real part of the result from step 5

Step7: Multiply (pixel by pixel multiplication) the result from step 6 by (-1)x+y to
get origin back to original position.

Fast Fourier Transform:


For the implementation of DFT it requires on the order of (MN)2 multiplications
and additions where as Fast Fourier Transform (FFT) reduces computation to the
order of MN*log2(MN) multiplication and additions. FFT is an algorithm to reduce
the computation time for DFT.

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.

By Lec. Pratik Chand, NCCS Page 32


Image Processing – CSIT 5th Semester

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.

Derivation of 1-D FFT

1-D FFT equation is defined as

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

With n being a positive integer, M can be expressed as

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) = ∑ ( ) +∑ ( )

By Lec. Pratik Chand, NCCS Page 33


Image Processing – CSIT 5th Semester

However, u and K are the positive integer so, we can write

=
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

Now the 1-D FFT equation is:

F(u) = Feven (u) + Fodd (u)


The Fast Fourier Transform (FFT) is a way to reduce the complexity of the Fourier
transform computation from O(n2) to O(n*log(n)), which is a dramatic
improvement. Hence, the time complexity of FFT is O(n*log(n))

Complexity analysis:

Time complexity of DFT = O(n2)

Time complexity of FFT = O(n*log(n))

By Lec. Pratik Chand, NCCS Page 34


Image Processing – CSIT 5th Semester

Let us take an example to understand it better. We have considered eight points


named from x0 to x7. We will choose the even terms in one group and the odd
terms in the other.

Diagrammatic view of the above said has been shown below

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.

By Lec. Pratik Chand, NCCS Page 35


Image Processing – CSIT 5th Semester

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.

Twiddle factor for FFT:

By Lec. Pratik Chand, NCCS Page 36


Image Processing – CSIT 5th Semester

Twiddle factor for IFFT:

By Lec. Pratik Chand, NCCS Page 37


Image Processing – CSIT 5th Semester

FFT:
FFT is used to change data from spatial domain to frequency domain

Spatial domain (Xn) ------- Frequency Domain (Xk)

FFT can be divided in to two parts

 Decimation in Time (DIT)


 Decimation in Frequency (DIF)

Decimation in Time (DIT-FFT)

Decimation means signal flow variation. In DIT-FFT sequence of input data in


spatial domain (Xn) have order variation.

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.

For 4 point (N=4):

Even = (0,2) Odd = (1,3)

For 8 point (N=8):

Even = (0,4,2,6) Odd = (1,5,3,7)

By Lec. Pratik Chand, NCCS Page 38


Image Processing – CSIT 5th Semester

Butterfly diagram for DIT-FFT:

For 4-point (N=4):

For 8-point (N=8):

By Lec. Pratik Chand, NCCS Page 39


Image Processing – CSIT 5th Semester

Decimation in Frequency (DIF-FFT)

In DIF-FFT sequence of output data in frequency domain (Xk) have order


variation.

Xn -------------- Xk
(Change)
This change means change in occurrence of sequence in frequency domain data.

For 4 point (N=4):

Even = (0,2) Odd = (1,3)

For 8 point (N=8):

Even = (0,4,2,6) Odd = (1,5,3,7)

Here the data occurrence in Xn is changed.

Butterfly Diagram for DIF-FFT:


For 4-point (N=4):

By Lec. Pratik Chand, NCCS Page 40


Image Processing – CSIT 5th Semester

For 8-point (N=8):

IFFT:
IFFT is used to change data from frequency domain to spatial domain

Frequency domain (Xk) ------- Spatial Domain (Xn)

IFFT can be divided in to two parts

 Decimation in Time (DIT)


 Decimation in Frequency (DIF)

Decimation in Time (DIT-IFFT):

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

For 4 point (N=4):

Even = (0,2) Odd = (1,3)

For 8 point (N=8):

Even = (0,4,2,6) Odd = (1,5,3,7)

Butterfly Diagram for DIT-IFFT:


For 4 point (N=4):

By Lec. Pratik Chand, NCCS Page 42


Image Processing – CSIT 5th Semester

For 8 point (N=8):

Butterfly Diagram for DIF-IFFT:


For 4 point (N=4):

By Lec. Pratik Chand, NCCS Page 43


Image Processing – CSIT 5th Semester

For 8 point (N=8):

Example 1: Find the DFT of given function using DIT-FFT

f(x) = {1,2,3,4}.

Solution:

Here, we have to transfer data from spatial domain to frequency domain.

By Lec. Pratik Chand, NCCS Page 44


Image Processing – CSIT 5th Semester

Hence, Xk = {10, -2+2j, -2, -2-2j} this is the DFT of given f(x).

3 step verification of result:

1. (N/2)th term of the result should be real number.


Here, N/2 = 4/2 = 2, so 2th position number is real i.e. -2, verified.
2. 1st term of result should be equals to sum of f(x).
Here, sum of f(x) = 10, and 1st term of result is also 10, verified.
3. Result should be Complex Conjugate.
Here, Result is complex conjugate, verified.

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.

By Lec. Pratik Chand, NCCS Page 45


Image Processing – CSIT 5th Semester

Example 2: Find the Inverse DFT (IDFT) of given function using DIT-IFFT

f(x) = {10, -2+2j, -2, -2-2j}.

Solution: Here, we have to convert frequency domain data to spatial domain.

Here, X0 = 1, X1 = 2, X2 = 3, X3 = 4

Hence, Xn = {1, 2, 3, 4} this is the IDFT of given function.

Verification of Result:

1. Sum of result should be equal to 1st term of given function.

Here, sum of result is 10, and 1st term of given function is also 10, verified.

By Lec. Pratik Chand, NCCS Page 46


Image Processing – CSIT 5th Semester

Example 3: Find the DFT of given function using DIT-FFT

F(x) = {1, 2, 4, 8, 16, 32, 64, 128}.

Solution: here we have to transfer spatial domain data to frequency domain

Here, N=8,

Hence, X,k = {255, 48.63+166.05j, -51+102j, -78.63+46.05j, -85, -78.63-46.05j,


-51-102j, 48.63-166.05j} this is the DFT of given function.

By Lec. Pratik Chand, NCCS Page 47


Image Processing – CSIT 5th Semester

Example 4: Find the IDFT of given function using DIT-IFFT

f(x) = {255, 48.63+166.05j, -51+102j, -78.63+46.05j, -85, -78.63-46.05j,


-51-102j, 48.63-166.05j}

Solution: here, we have to transfer frequency domain data to spatial domain

Here, N=8

Here, X0 = 1, X1 = 2, X2 = 4, X3 = 8, X4 = 16, X5 = 32, X6 = 64, X7 = 128

Hence, Xn = {1, 2, 4, 8, 16, 32, 64, 128} this is the IDFT of given function.

By Lec. Pratik Chand, NCCS Page 48


Image Processing – CSIT 5th Semester

Discrete Cosine Transform (DCT):


The term “Transform” means to change form or appearance. In terms of signal
processing, a transform is normally a tool that is used to convert the signals from
time domain or spatial domain to the frequency domain.

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.

Image Compression: Image is stored or transmitted with having pixel value. It


can be compressed by reducing the value its every pixel contains. Image
compression is basically of two types:

2. Lossless compression: In this type of compression, after recovering image


is exactly become same as that was before applying compression techniques
and so, its quality didn’t gets reduced.
3. Lossy compression: In this type of compression, after recovering we can’t
get exactly as older data and that’s why the quality of image gets
significantly reduced. But this type of compression results in very high
compression of image data and is very useful in transmitting image over
network.

Discrete Cosine Transform is used in lossy image compression because it has


very strong energy compaction, i.e., its large amount of information is stored in
very low frequency component of a signal and rest other frequency having very
small data which can be stored by using very less number of bits (usually, at most
2 or 3 bit).

To perform DCT Transformation on an image, first we have to fetch image file


information (pixel value in term of integer having range 0 – 255) which we divides
in block of 8x8 Matrix and then we apply discrete cosine transform on that block
of data. DCT is basically used for JPEG image compression.

By Lec. Pratik Chand, NCCS Page 49


Image Processing – CSIT 5th Semester

Complexity of DCT:

Time Complexity: O((nm)2)

Auxiliary Space: O(nm)

One-Dimensional DCT:

The 1-D DCT is defined by the equation

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.

By Lec. Pratik Chand, NCCS Page 50


Image Processing – CSIT 5th Semester

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.

DCT using Matrix Method:

We can perform DCT operation using matrix method.

For 1-D DCT:

F(k) = Mask*f(x)

For 2-D DCT:


F(u,v) = Mask*f(x,y)*MaskT

The transpose mask or kernel of DCT is given bellow.

4-point mask:

Example 1: Find the DCT of f(x) = {1, 2, 4, 7}.

Solution:

Here, given function is 1D

So, F(k) = Mask*f(x)

By Lec. Pratik Chand, NCCS Page 51


Image Processing – CSIT 5th Semester

7
-4.4604
1
-0.3172

Hence, F(k) = {7, -4.4604, 1, -0.3172}

Example 2:

Solution:

F(u,v) = Mask*f(x,y)*MaskT

Mask MaskT

By Lec. Pratik Chand, NCCS Page 52


Image Processing – CSIT 5th Semester

Haar Transformation:
Haar transform is used in image compression. This is efficient to use in both lossy
and lossless image compression techniques.

1-D Haar transform:

F(k) = Mask*f(x)

2-D Haar transform:

F(k,l) = Mask*f(m,n)*MaskT

By Lec. Pratik Chand, NCCS Page 53


Image Processing – CSIT 5th Semester

Mask for 2x2 Image Transform:

Mask for 4x4 Image Transform:

By Lec. Pratik Chand, NCCS Page 54


Image Processing – CSIT 5th Semester

Example:

By Lec. Pratik Chand, NCCS Page 55


Image Processing – CSIT 5th Semester

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.

1-D Hadamard Transform:

F(k) = Mask*f(x)

2-D Hadamard Transform:


F(k,l) = Mask*f(x,y)*MaskT

Hadamard mask for 2x2 Image Transform:

H2x2 =

1 1
1 -1

Hadamard mask for 4x4 Image Transform:

H4x4 =

1 1 1 1
1 -1 1 -1
1 1 -1 -1
1 -1 -1 1

By Lec. Pratik Chand, NCCS Page 56


Image Processing – CSIT 5th Semester

Example 1: find the DFT of given function using Hadamard Transform

F(x) = {1, 2, 0, 3}

Solution:
F(k) = Mask*f(x)

* =

Hence, F(k) = {6, -4, 0, 2}

Properties of Hadamard Transformation:

1. Hadamard transform contains any one value.


2. No multiplications are required in the transform calculations.
3. The no: of additions or subtractions required can be reduced from N2 to
4. N log2 N
5. Very good energy compaction for highly correlated images.

End of Unit-3

By Lec. Pratik Chand, NCCS Page 57

You might also like