0% found this document useful (0 votes)
39 views

Module 02 Dip

This document discusses 2D discrete Fourier transforms (DFT) and their properties of translation and rotation. It also discusses using frequency domain filters for image smoothing and sharpening. Specifically, it explains that image smoothing filters attenuate high frequencies while preserving low frequencies, resulting in a blurred image. Image sharpening filters do the opposite, enhancing edges by boosting high frequencies. Common filters for each purpose like Gaussian, Laplacian, and unsharp mask are also mentioned. Further, it discusses various spatial domain filters for image smoothing, such as Gaussian, median, and bilateral filters, noting each has strengths for different noise types and applications.

Uploaded by

Inchara Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Module 02 Dip

This document discusses 2D discrete Fourier transforms (DFT) and their properties of translation and rotation. It also discusses using frequency domain filters for image smoothing and sharpening. Specifically, it explains that image smoothing filters attenuate high frequencies while preserving low frequencies, resulting in a blurred image. Image sharpening filters do the opposite, enhancing edges by boosting high frequencies. Common filters for each purpose like Gaussian, Laplacian, and unsharp mask are also mentioned. Further, it discusses various spatial domain filters for image smoothing, such as Gaussian, median, and bilateral filters, noting each has strengths for different noise types and applications.

Uploaded by

Inchara Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

MODULE 02

1. Define 2D- DFT. Explain the following properties of 2D-DFT i) Translation ii)
Rotation
The 2D-DFT (Two-Dimensional Discrete Fourier Transform) is an important
mathematical tool used in signal processing, image processing, and various other fields
to analyze and process 2D data. It extends the concept of the 1D-DFT to two
dimensions, allowing us to transform a 2D signal (e.g., an image) from the spatial
domain to the frequency domain.

1. 2D-DFT Definition:
Let's assume we have a 2D signal represented as a matrix of complex numbers with
dimensions MxN (M rows and N columns). The 2D-DFT of this signal is defined as
follows:

For each frequency component (u, v) in the output frequency domain, the 2D-DFT is
given by the formula:

X(u, v) = Σ Σ x(m, n) * exp(-j * 2 * π * ((u * m) / M + (v * n) / N))

where x(m, n) represents the elements of the 2D input signal, X(u, v) represents the
transformed coefficients in the frequency domain, j is the imaginary unit (sqrt(-1)), and
Σ indicates summation over all values of m (from 0 to M-1) and n (from 0 to N-1).

The 2D-DFT decomposes the input signal into a sum of complex exponential functions
with varying frequencies (u, v). These frequency components represent the amplitude
and phase information of different spatial frequencies present in the input signal.

2. Properties of 2D-DFT:

a. Translation Property:
The translation property of the 2D-DFT states that if we shift the input signal in the
spatial domain, it will cause a linear phase shift in the frequency domain. More
specifically, if we translate the input signal by (p, q) in the spatial domain, the
corresponding frequency domain representation becomes:

X(u, v) = X(u, v) * exp(-j * 2 * π * ((p * u) / M + (q * v) / N))

In simple terms, shifting an image in the spatial domain will result in a corresponding
phase shift in the frequency domain, and the magnitude of the frequency components
remains unaffected.

b. Rotation Property:
The rotation property of the 2D-DFT states that if we rotate the input signal in the spatial
domain, it will cause a circular shift in the frequency domain. The amount of circular
shift depends on the rotation angle. Mathematically, if we rotate the input signal by an
angle θ, the corresponding frequency domain representation becomes:
X(u, v) = X(u', v')

where u' and v' are the transformed frequency components after rotation, and they are
related to the original frequency components (u, v) as follows:

u' = u * cos(θ) - v * sin(θ)


v' = u * sin(θ) + v * cos(θ)

In summary, rotating an image in the spatial domain leads to a circular shift in the
frequency domain of the 2D-DFT coefficients.

These properties are essential in various applications such as image registration, image
alignment, and pattern recognition, where understanding the behavior of the 2D-DFT
under translations and rotations is crucial for accurate analysis and manipulation of
images.
2. Explain Image Smoothing and Image Sharpening Using Frequency Domain
Filters.
Image smoothing and image sharpening (also known as image enhancement) are two
common image processing techniques that can be achieved using frequency domain
filters. These techniques are used to alter the appearance of an image by manipulating
its frequency components.

1. Image Smoothing:
Image smoothing aims to reduce noise or fine details in an image, resulting in a more
visually pleasing and less noisy output. It is typically used to blur an image and create
a softer appearance. Frequency domain filters used for image smoothing are designed
to attenuate high-frequency components while preserving or reducing low-frequency
components.

In the frequency domain, images can be represented by their Fourier Transform. The
high-frequency components in the Fourier domain correspond to fine details and noise,
while low-frequency components represent the overall structure and main features of
the image.

To perform image smoothing using frequency domain filters, the general steps are as
follows:

a. Compute the Fourier Transform of the input image.


b. Design a filter function in the frequency domain that attenuates high-frequency
components and preserves or reduces low-frequency components.
c. Apply the filter to the Fourier Transform of the image.
d. Compute the inverse Fourier Transform to convert the filtered image back to the
spatial domain.
The result is a smoothed version of the original image, with reduced noise and fine
details.

2. Image Sharpening (Image Enhancement):


Image sharpening is a technique used to highlight the fine details and edges in an image,
making it appear clearer and more defined. This process involves enhancing the high-
frequency components while suppressing the low-frequency components.

To perform image sharpening using frequency domain filters, the general steps are as
follows:

a. Compute the Fourier Transform of the input image.


b. Design a filter function in the frequency domain that enhances high-frequency
components while attenuating low-frequency components.
c. Apply the filter to the Fourier Transform of the image.
d. Compute the inverse Fourier Transform to convert the filtered image back to the
spatial domain.

The result is a sharpened version of the original image, with enhanced edges and details.

In both cases, the key to success lies in designing an appropriate frequency domain
filter. Common filter types used for image smoothing include Gaussian filters and
averaging filters. On the other hand, for image sharpening, high-pass filters like the
Laplacian or the unsharp mask are often employed.

It's important to note that while frequency domain filtering can achieve desirable
results, it may be computationally intensive for large images. Therefore, in practical
applications, many real-time image processing tasks use spatial domain filters or hybrid
approaches to strike a balance between efficiency and effectiveness.

3. IMAGE SMOOTHIG AND SHARPENING FILTERS AND IMAGE FILTERING


IN SPATIAL DOMAIN
Image smoothing, also known as image blurring or image filtering, is a common image
processing technique used to reduce noise and remove fine details from an image.
Smoothing is often used as a preprocessing step to enhance the quality of an image or
to make it easier to analyze or process.

There are various special filters used for image smoothing, each with its own
characteristics and applications. Let's explore some of the most common ones:

1. *Gaussian Filter:*
The Gaussian filter is one of the most widely used filters for image smoothing. It
applies a Gaussian function to calculate the weighted average of pixels in the
neighborhood. The closer a pixel is to the center of the kernel, the higher the weight it
receives. This filter effectively reduces high-frequency noise while preserving the
overall structure of the image.

2. *Median Filter:*
The median filter is a nonlinear filter that replaces the value of each pixel with the
median value of its neighboring pixels. It is particularly effective at removing impulse
noise or salt-and-pepper noise, where random pixels are significantly different from
their surroundings. The median filter preserves edges well but may not be as effective
in reducing Gaussian noise.

3. *Mean Filter:*
The mean filter, also known as the average filter, calculates the average value of pixels
within a neighborhood and assigns it to the center pixel. While simple to compute, the
mean filter is not as effective as Gaussian filtering in preserving image details, and it
can produce blurring effects.

4. *Bilateral Filter:*
The bilateral filter is a non-linear, edge-preserving smoothing filter. It considers both
the spatial closeness and pixel intensity similarity between the center pixel and its
neighbors. The bilateral filter can reduce noise while preserving edges, making it
suitable for applications where noise reduction is needed without compromising
important features.

5. *Anisotropic Diffusion:*
Anisotropic diffusion is a partial differential equation-based smoothing technique. It
diffuses the image, but the diffusion process is guided by the image's gradient. This
means that edges are preserved while smoothing takes place in flat regions. It is
effective for preserving sharp edges in noisy images.

6. *Total Variation (TV) Filter:*


The total variation filter aims to minimize the total variation of pixel intensities while
smoothing the image. It is used to denoise images while preserving important features.
The TV filter is suitable for images with a piecewise-constant structure.

7. *Guided Filter:*
The guided filter is an edge-preserving filter that uses a guidance image (usually the
original image itself or a simplified version of it) to control the smoothing process. It
can be used for various tasks like image enhancement, dehazing, and denoising.

Each smoothing filter has its strengths and weaknesses, and the choice of filter depends
on the specific application and the characteristics of the image being processed. The
performance of the filter can also be affected by the filter's kernel size or other
parameters that may need to be adjusted for optimal results
Image sharpening is a technique used to enhance the details and edges in an image,
making it appear clearer and more focused. One common method of image sharpening
involves using first-order derivatives, specifically the gradient of the image, to
accentuate edges.

The first-order derivative used for image sharpening is typically computed using an
operator called a "kernel" or "filter." The most common filter for sharpening is the
Laplacian filter. The Laplacian operator calculates the second derivative of the image
intensity with respect to both the x and y directions. However, since we're interested in
using first-order derivatives for sharpening, we approximate the Laplacian filter using
the first-order derivative filters, such as the Sobel or Prewitt filters.

Here's a high-level overview of the process:

1. Grayscale Conversion: If the image is in color, it's first converted to grayscale


because image sharpening is usually performed on the intensity values rather than
individual color channels.

2. Gradient Calculation: The first-order derivatives (gradients) of the image are


calculated using convolution. Convolution is a mathematical operation that involves
sliding a small filter/kernel over the entire image and computing the sum of element-
wise products.

3. Edge Enhancement: The gradient image highlights edges and areas with significant
intensity changes. To enhance the edges, the original image is combined with the
gradient image. This can be done through various methods, including:

a. Adding the gradient image to the original image.


b. Multiplying the gradient image by a factor and adding it to the original image.
c. Using a process called "unsharp masking," where a blurred version of the original
image is subtracted from the original image before adding the gradient image.

4. Clipping: Since the result of adding the gradient may lead to pixel values outside the
valid range (0 to 255 for an 8-bit image), the values may need to be clipped to ensure
they are within the appropriate range.

The end result is an image with enhanced edges and more pronounced details. The
sharpening process works by increasing the intensity contrast at the edges, which makes
them more visible to the human eye.

It's essential to be cautious with image sharpening, as aggressive sharpening can lead
to unwanted artifacts and noise. Therefore, it's often applied in a controlled manner, and
different approaches can be used to balance the sharpening effect with preserving a
natural appearance in the image.
Image Filtering in Spatial Domain:

Image filtering in the spatial domain is a fundamental technique used for various image
processing tasks such as noise reduction, edge detection, and feature enhancement.
Spatial domain filtering involves directly manipulating the pixel values of an image
based on a predefined filter/kernel.

The most common spatial domain filter is the linear convolution filter, where a small
matrix (the kernel) is applied to each pixel and its neighboring pixels. The kernel is
typically a small window with specific coefficients that define how the convolution
operation is performed.

The steps for image filtering in the spatial domain are as follows:
1. Place the kernel at the center of each pixel in the image.
2. Perform element-wise multiplication of the kernel with the corresponding pixel
neighborhood.
3. Sum up the results of the multiplication to obtain the new pixel value for the center
pixel.
4. Repeat this process for all pixels in the image.

There are various types of spatial domain filters, including:

a. Smoothing Filters: Used for noise reduction and blurring. Examples include the Box
filter, Gaussian filter, and Median filter.

b. Edge Detection Filters: Enhance and highlight edges in the image. Common edge
detection filters include the Sobel filter, Prewitt filter, and Roberts cross filter.

c. Sharpening Filters: Enhance fine details and edges in the image. Examples include
the Laplacian filter and Unsharp mask filter.

Image filtering in the spatial domain is straightforward and computationally efficient,


making it widely used in many image processing applications. However, it has
limitations, such as difficulties in handling large kernels and the potential introduction
of artifacts. To address these issues, other frequency domain-based techniques like Fast
Fourier Transform (FFT) filtering are employed.
4. DEFINE HISTOGRAM AND Explain (i) Histogram sliding and Histogram
stretching
A histogram is a graphical representation of the distribution of data in a dataset. It is a
type of bar chart that shows the frequency or count of values falling within certain
ranges or bins. The data is divided into intervals (bins), and the height of each bar in
the histogram represents the number of data points that fall within that particular bin.

The horizontal axis of the histogram represents the range of values or intervals, and the
vertical axis represents the frequency or count of data points falling into each interval.
Each bar is typically adjacent to the next one, as the intervals are continuous.
Histograms are commonly used to visualize the underlying distribution of data and to
identify patterns, central tendencies, and outliers within the dataset. They are especially
useful when dealing with large datasets or when exploring the shape of the data
distribution. Histograms are widely used in various fields, including statistics, data
analysis, and data visualization.

Histogram Sliding and Histogram Stretching:

Histogram Sliding and Histogram Stretching are two image enhancement techniques
used to improve the contrast and brightness of an image. They operate in the spatial
domain and are based on the image's histogram, which represents the distribution of
pixel intensities.

1. Histogram Sliding:
Histogram Sliding, also known as Contrast Stretching, is a simple technique to improve
the contrast of an image by stretching the pixel intensity values across the entire
dynamic range. The process involves mapping the original intensity range to a new
desired range.

The steps for histogram sliding are as follows:


a. Compute the histogram of the input image.
b. Determine the minimum and maximum pixel intensities in the histogram.
c. Define a new desired range for pixel intensities, typically the full range (e.g., 0 to
255 for 8-bit images).
d. Perform pixel mapping, where each pixel value in the original range is linearly
transformed to the new desired range.

The formula for pixel mapping is as follows:


NewPixelValue = (OriginalPixelValue - MinIntensity) * (NewRange / (MaxIntensity -
MinIntensity))

Histogram Sliding effectively spreads the pixel intensities to cover the entire range, thus
enhancing the image's contrast.

2. Histogram Stretching:
Histogram Stretching is similar to Histogram Sliding, but it allows for a more flexible
mapping of pixel intensities. Instead of just stretching the histogram to the full range, it
allows the user to specify the desired minimum and maximum intensities.

The steps for histogram stretching are as follows:


a. Compute the histogram of the input image.
b. Determine the minimum and maximum pixel intensities in the histogram.
c. Define the desired minimum and maximum intensities for the output image.
d. Perform pixel mapping, where each pixel value in the original range is linearly
transformed to the new specified range.
The formula for pixel mapping is as follows:
NewPixelValue = (OriginalPixelValue - MinIntensity) * (NewRange / (MaxIntensity -
MinIntensity)) + NewMinIntensity

Histogram stretching allows more control over the enhancement process, as it lets the
user adjust the output intensity range to achieve the desired level of contrast.
5. Derive formula for Laplacian operation and suggest 3X3 mask to implement it.
I assume you are referring to the Laplacian operator in mathematics, which is often
denoted by the symbol ∇² (del squared). The Laplacian operator is used in various fields,
such as physics, engineering, and image processing, to describe the divergence of a
gradient or the second derivative of a scalar field.

The Laplacian operator in Cartesian coordinates (x, y, z) is given by:

∇²f = ∂²f/∂x² + ∂²f/∂y² + ∂²f/∂z²

where ∂²f/∂x² represents the second partial derivative of the function f with respect to
x, and similarly for y and z.

If you want to implement a discrete approximation of the Laplacian operator on a 3x3


grid, you can use finite difference methods to estimate the second derivatives.

One common approach is to use the 3x3 convolution kernel:

1 1 1
1 -8 1
1 1 1

To compute the Laplacian of a pixel (i, j) in an image, you would perform the following
operation:

Laplacian(i, j) = (pixel(i-1, j) + pixel(i+1, j) + pixel(i, j-1) + pixel(i, j+1)) - 8 * pixel(i,


j)

Here, pixel(i, j) represents the intensity value at position (i, j) in the image.

Keep in mind that this is a basic implementation of the Laplacian operator, and more
advanced methods like the use of Gaussian smoothing before Laplacian or other edge
detection techniques are often used to improve results in image processing applications.
Also, there are other discretization schemes available for the Laplacian, such as using
central differences, depending on the specific application and requirements.

As for the suggested 3x3 marks, I assume you meant 3x3 grids or kernels for
implementing the Laplacian. The ones I've already provided is a classic choice for basic
edge detection. However, if you want to explore other options, you can consider:
1. Central Difference Kernel:

0 1 0
1 -4 1
0 1 0

2. Diagonal Difference Kernel:

1 1 1
1 -8 1
1 1 1

Remember that different kernels will have varying sensitivities to different patterns and
edges, so you may need to experiment and choose the one that best suits your specific
use case.
6. Mention key properties of DFT, also Determine IDFT for { 20, -7+7j; -2, -7-7j }
Properties of Discrete Fourier Transform (DFT):

1. Linearity: The DFT is a linear transformation, which means it satisfies the


superposition principle. If x[n] and y[n] are two sequences, and a and b are constants,
then the DFT of (ax[n] + by[n]) is equal to a times the DFT of x[n] plus b times the
DFT of y[n].

2. Circular time-shift property: If x[n] has a DFT X[k], then the DFT of x[n - m] is
equal to X[k] multiplied by exp(-j2πmk/N), where N is the length of the sequence.

3. Circular convolution property: The DFT of the circular convolution of two sequences
x[n] and y[n] is equal to the element-wise product of their DFTs, i.e., DFT(x[n] * y[n])
= X[k] * Y[k].

4. Periodicity: The DFT of a periodic sequence results in impulses at equally spaced


intervals in the frequency domain.

5. Parseval's Theorem: The sum of squares of the magnitudes of the DFT coefficients
is equal to the sum of squares of the original sequence values.

Inverse Discrete Fourier Transform (IDFT):

The IDFT reconstructs the original sequence from its DFT coefficients. It is given by:

x[n] = (1/N) * Σ [k=0 to N-1] (X[k] * exp(j2πkn/N))

Where:
- N is the length of the sequence.
- X[k] is the k-th DFT coefficient of the sequence x[n].
IDFT for the given sequence {20, -7 + 7j, -2, -7 - 7j} can be calculated as follows:

N = 4 (since there are 4 elements in the sequence)


n = 0, 1, 2, 3

x[0] = (1/4) * [20 + (-7 + 7j) + (-2) + (-7 - 7j)]


= (1/4) * [20 - 2 - 7 + (-7) + 7j - 7j]
= (1/4) * [4 - 7]
= -3/4

x[1] = (1/4) * [20 + (-7 + 7j) * exp(j2π*1/4) + (-2) * exp(j2π*2/4) + (-7 - 7j) *
exp(j2π*3/4)]
= (1/4) * [20 + (-7 + 7j) * j + (-2) * (-1) + (-7 - 7j) * (-j)]
= (1/4) * [20 + (-7j - 7 + 2 + 7j)]
= (1/4) * [15]
= 15/4

x[2] = (1/4) * [20 + (-7 + 7j) * exp(j2π*2/4) + (-2) * exp(j2π*4/4) + (-7 - 7j) *
exp(j2π*6/4)]
= (1/4) * [20 + (-7 + 7j) * (-1) + (-2) * (1) + (-7 - 7j) * 1]
= (1/4) * [20 - 7 + 7j - 2 - 7 - 7j]
= (1/4) * [4 - 7]
= -3/4

x[3] = (1/4) * [20 + (-7 + 7j) * exp(j2π*3/4) + (-2) * exp(j2π*6/4) + (-7 - 7j) *
exp(j2π*9/4)]
= (1/4) * [20 + (-7 + 7j) * (-j) + (-2) * 1 + (-7 - 7j) * j]
= (1/4) * [20 - 7j + 7 + 2 - 7 + 7j]
= (1/4) * [29]
= 29/4

So, the IDFT of the given sequence {20, -7 + 7j, -2, -7 - 7j} is: {-3/4, 15/4, -3/4, 29/4}.

7. Write transfer function for High Pass and low pass Filter
Transfer Function for High Pass Filter:

A high-pass filter allows signals with frequencies higher than a certain cutoff frequency
to pass through and attenuates frequencies below the cutoff. One common type of high-
pass filter is the first-order Butterworth filter.

The transfer function for a first-order Butterworth high-pass filter is given by:

H_HP(s) = (s / (s + ω_c))

Where:
- H_HP(s) is the transfer function of the high-pass filter.
- s is the complex frequency variable (s = σ + jω), with σ being the real part and ω being
the angular frequency.
- ω_c is the cutoff angular frequency.

Transfer Function for Low Pass Filter:

A low-pass filter allows signals with frequencies lower than a certain cutoff frequency
to pass through and attenuates frequencies above the cutoff. Again, we'll consider a
first-order Butterworth filter as an example.

The transfer function for a first-order Butterworth low-pass filter is given by:

H_LP(s) = (ω_c / (s + ω_c))

Where:
- H_LP(s) is the transfer function of the low-pass filter.
- s is the complex frequency variable (s = σ + jω), with σ being the real part and ω being
the angular frequency.
- ω_c is the cutoff angular frequency.

Please note that in practice, the cutoff frequency ω_c is determined based on the filter
design requirements. Also, to convert these continuous-time transfer functions to
discrete-time for digital filter implementation, appropriate methods like the bilinear
transform or impulse invariance are used.
8. Perform inversion, square root, square, logarithm and power function with c =1
and γ = 1.2 for the image shown below:
The "Inversion Square Root Square" algorithm and the "Power function" are commonly
used image processing operations to adjust the pixel intensities for enhancing contrast.
The "Inversion Square Root Square" algorithm is also known as the "Root Square"
transform, and the "Power function" is often referred to as "Gamma correction."

Let's perform these operations on the image shown below:

Original Image:
123
456
789

1. Inversion Square Root Square (Root Square) Algorithm:


The Root Square algorithm is defined as:
Output pixel value = sqrt(sqrt(255) - (Input pixel value)).

Using this algorithm, we'll compute the transformed image:

Transformed Image:
Output pixel values (rounded to the nearest integer):

(sqrt(sqrt(255) - 1)) = 3
(sqrt(sqrt(255) - 2)) = 3
(sqrt(sqrt(255) - 3)) = 2
(sqrt(sqrt(255) - 4)) = 2
(sqrt(sqrt(255) - 5)) = 1
(sqrt(sqrt(255) - 6)) = 1
(sqrt(sqrt(255) - 7)) = 1
(sqrt(sqrt(255) - 8)) = 0
(sqrt(sqrt(255) - 9)) = 0

Transformed Image:
332
211
100

2. Power Function (Gamma Correction):


The Power function (Gamma correction) is defined as:
Output pixel value = 255 * (Input pixel value / 255) ^ gamma.

Using this algorithm with c = 1 and gamma = 1.2, we'll compute the transformed image:

Transformed Image:
Output pixel values (rounded to the nearest integer):

(255 * (1 / 255) ^ 1.2) ≈ 1


(255 * (2 / 255) ^ 1.2) ≈ 2
(255 * (3 / 255) ^ 1.2) ≈ 4
(255 * (4 / 255) ^ 1.2) ≈ 6
(255 * (5 / 255) ^ 1.2) ≈ 8
(255 * (6 / 255) ^ 1.2) ≈ 9
(255 * (7 / 255) ^ 1.2) ≈ 11
(255 * (8 / 255) ^ 1.2) ≈ 13
(255 * (9 / 255) ^ 1.2) ≈ 14

Transformed Image:
124
236
348

Keep in mind that the pixel values are rounded to the nearest integer for the transformed
images. Actual image processing software might handle pixel values differently,
considering factors like normalization and handling of out-of-range values.

You might also like