0% found this document useful (0 votes)
19 views30 pages

CV Unit 1

computer vision unit 1 notes

Uploaded by

Sourabh Singh
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)
19 views30 pages

CV Unit 1

computer vision unit 1 notes

Uploaded by

Sourabh Singh
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/ 30

Computer Vision – Lecture Notes – Unit 1

1. Introduction to Digital Image Representation


• Definition: Digital image representation refers to the method by which images are
encoded for storage and processing in digital systems.
• Importance: Crucial in fields like photography, computer vision, and medical imaging.
• Components: Comprises pixels, color models, and file formats.

1.1.Pixels and Resolution


• Pixels: Smallest unit of a digital image, representing a single point of color.
• Example: A 1920x1080 image has 2,073,600 pixels.
• Resolution: Determined by the number of pixels (width x height).
• Higher resolution = more detail.

1.2.Color Models
• RGB (Red, Green, Blue):
• Description: Combines red, green, and blue light to create colors.
• Example: Colors on computer screens and digital cameras.
• CMYK (Cyan, Magenta, Yellow, Black):
• Usage: Mainly in printing to achieve a wide range of colors.

1.3.Bit Depth and Image Quality


• Bit Depth: Number of bits used to represent each pixel’s color.
• Example: An 8bit image can represent 256 colors.
• Impact on Quality: Higher bit depth = more colors = better image quality.

1.4.Image File Formats


• JPEG (Joint Photographic Experts Group):
• Usage: Compresses images, lossy format.
• Example: Suitable for photographs on the web.
• PNG (Portable Network Graphics):
• Usage: Lossless compression, retains quality.
• Example: Used for graphics with sharp edges or transparency.

1.5.Digital Image Processing


Operations: Manipulating images to enhance quality or extract information.
Examples: Resize, crop, adjust brightness/contrast.
2. Introduction to Sampling and Quantization
• Definition: Sampling and quantization are fundamental processes in digital image
processing that convert continuous analog signals (like light intensity) into discrete
digital signals (like pixels with specific colors).
• Purpose: Essential for converting real world images into digital format for storage,
transmission, and processing.

2.1.Sampling
• Definition: Sampling refers to capturing the continuous spatial information of an image
at discrete points called pixels.
• Example: Imagine taking a photograph with a digital camera.
o The camera sensor captures the image by sampling the scene at regular intervals,
converting light intensity at each point into digital values.
• Sampling Rate: Determined by pixel density (resolution).
o Higher resolution = more pixels = finer details.

2.2.Quantization
• Definition: Quantization involves assigning discrete digital values (often in bits) to each
sample obtained through sampling.
• Example: If an image is captured with 8bit quantization:
o Each pixel can have one of 256 possible intensity levels (0 to 255 in grayscale).
o For color images, quantization applies separately to each color channel (RGB
or CMYK).
• Impact of Quantization:
o Higher bit depth (more bits per pixel) results in more shades of color and better
image quality.

2.3.Sampling and Quantization Process


• Step-by-step Process:
o Sampling: Capture image at discrete points (pixels).
o Quantization: Assign digital values to each sample based on bit depth.
• Example:
o A grayscale image with 8bit quantization allows for 256 shades of grey.
o A color image with 24bit (8 bits per channel) quantization allows for over 16
million colors.

2.4.Sampling Theorem (Nyquist Shannon Sampling Theorem)


• Principle: States that to accurately reconstruct a signal (or image) from samples, the
sampling rate must be at least twice the highest frequency present in the signal.
• Application: Ensures no loss of information during sampling.

2.5.Effects of Sampling and Quantization


• Aliasing: Occurs when sampling rate is too low, causing high frequency details to
be lost or misrepresented (seen as jagged edges or moiré patterns).
• Quantization Errors: Visible as noise or banding in low bit depth images.
• Trade-offs: Balancing between high resolution (more detail) and file size (storage
considerations).

2.6.Image File Formats and Sampling/Quantization


• File Formats: JPEG, PNG, TIFF, etc., handle sampling and quantization differently:
o JPEG uses lossy compression affecting quantization levels.
o PNG retains full quality with lossless compression.
3. Steps in Image Processing

Image processing involves a series of steps to enhance, analyse, and understand images. It is
widely used in fields like medical imaging, remote sensing, computer vision, and more. The
process typically includes various stages, each with specific techniques and methods to
manipulate and improve the quality of an image.

3.1.Steps in Image Processing


• Image Acquisition
• Image Preprocessing
• Segmentation
• Feature Extraction
• Image Representation and Description
• Recognition and Interpretation
• Postprocessing

3.1.1. Image Acquisition


• Definition: This is the first step where an image is captured by a sensor (such as a
camera) and converted into a digital form.
• Example: Using a digital camera to take a picture of a landscape.

Details:
• The image is typically represented as a grid of pixels.
• Each pixel has a value corresponding to the intensity or color of the image at that point.
• The resolution and quality of the image depend on the sensor's specifications.

3.1.2. Image Preprocessing


• Definition: Preprocessing involves preparing the image for further processing by
enhancing its quality and removing any distortions or noise.
• Example: Enhancing the contrast of an image to make it clearer.

Techniques:
• Noise Reduction: Using filters (e.g., Gaussian, median) to remove noise.
• Contrast Enhancement: Adjusting the brightness and contrast.
• Normalization: Scaling pixel values to a standard range.

Details:
• This step aims to improve the image quality for better analysis.
• Common techniques include smoothing, sharpening, and histogram equalization.

3.1.3. Segmentation
• Definition: Segmentation involves dividing the image into meaningful regions or
objects.

• Example: Separating the foreground (e.g., a person) from the background (e.g., a room).
Techniques:
• Thresholding: Converting an image to binary by setting a threshold.
• Edge Detection: Using operators like Sobel or Canny to find edges.
• Region-based Segmentation: Dividing the image based on similarities in intensity or
color.

Details:
• The goal is to simplify the image and focus on specific parts for further analysis.
• This step is crucial for object detection and recognition tasks.

3.1.4. Feature Extraction


• Definition: This step involves identifying and extracting important features or
characteristics from the segmented regions.
• Example: Extracting the edges, corners, or textures of an object.

Techniques:
• Edge Features: Detecting edges using gradient operators.
• Shape Features: Identifying geometric shapes and contours.
• Texture Features: Analysing the surface texture using methods like GLCM (Gray Level
Cooccurrence Matrix).

Details:
• Features are used to describe the objects in the image.
• These features are essential for classification and recognition.

3.1.5. Image Representation and Description


• Definition: This step involves representing the extracted features in a suitable form for
further analysis.
• Example: Representing a detected shape using its boundary coordinates.

Techniques:
• Boundary Representation: Using curves or polygons to describe the shape.
• Region Representation: Using properties like area, centroid, and moments.

Details:
• The choice of representation depends on the application.
• Effective representation is key for accurate analysis and interpretation.

3.1.6. Recognition and Interpretation


• Definition: This step involves identifying and interpreting the objects or patterns in the
image based on the extracted features.
• Example: Recognizing a handwritten digit as a specific number.

Techniques:
• Classification: Using machine learning algorithms (e.g., SVM, neural networks) to
classify objects.
• Pattern Matching: Comparing features with a known set of patterns.

Details:
• This step is crucial for applications like face recognition, object detection, and medical
diagnosis.
• The accuracy of recognition depends on the quality of feature extraction and
representation.

3.1.7. Postprocessing
• Definition: Postprocessing involves refining the results obtained from recognition and
interpretation.
• Example: Removing false positives from detected objects.

Techniques:
• Morphological Operations: Using operations like dilation and erosion to clean up the
results.
• Filtering: Applying filters to enhance the final output.

Details:
• Postprocessing helps in improving the accuracy and reliability of the results.
• It is often tailored to specific applications and requirements.
4. Image acquisition

4.1.Introduction to Image Acquisition


• Definition: Image acquisition refers to the process of capturing images from the real
world using various devices such as cameras, scanners, or medical imaging equipment.
• Importance: It is the first step in the digital image processing pipeline, crucial for
subsequent analysis and manipulation.

4.2.Methods of Image Acquisition

4.2.1. Digital Cameras:


• Description: Capture images using light sensitive sensors (CCD or CMOS) and lenses.
• Example: DSLRs, smartphone cameras.
• Process: Light enters through the lens, hits the sensor, converted into digital signals
(RGB), and stored as image files (JPEG, RAW).

4.2.2. Scanners:
• Description: Convert physical documents or images into digital form.
• Example: Flatbed scanners for documents, film scanners for negatives.
• Process: Reflective or transmissive light scans the document, converted into digital data
(often grayscale or color).

4.2.3. Medical Imaging:


• Description: Used in healthcare for diagnostic purposes.
• Examples: Xrays, MRIs, CT scans.
• Process: Different modalities (Xrays, magnetic fields, etc.) generate images based on
tissue density or other properties.

4.2.4. Satellite Imaging:


• Description: Capture images of Earth's surface for various applications (mapping,
weather forecasting, etc.).
• Examples: Landsat, MODIS, commercial satellites.
• Process: Sensors onboard satellites capture electromagnetic radiation reflected or
emitted from the Earth's surface.

4.3.Parameters Influencing Image Acquisition

• Resolution: Determines the level of detail captured.


• Higher resolution = more pixels = finer details.
• Sensor Type: CCD (Charge-Coupled Device) or CMOS (Complementary MetalOxide
Semiconductor) sensors affect image quality and sensitivity.
• Optics: Quality of lenses impacts sharpness, distortion, and light transmission.
• Lighting Conditions: Natural or artificial light affects image brightness and color
accuracy.
• Shutter Speed and Exposure: Control over how much light enters the sensor, affecting
motion blur and image brightness.

4.4.Challenges in Image Acquisition

• Noise: Unwanted variations in brightness or color due to sensor limitations or


environmental factors.
• Distortion: Lens aberrations or perspective distortions.
• Artifacts: Unintended features in images, like compression artifacts or moiré patterns.

4.5.Image Formats and Compression

• File Formats: JPEG, PNG, TIFF, RAW, etc., store images with varying levels of
compression and quality.
• Compression: Lossy (JPEG) vs. lossless (PNG, TIFF) compression methods impact
image fidelity and file size.
5. Color Image representation

5.1.Introduction
Color image representation involves the methods and formats used to digitally store and
manipulate color information in images. Understanding how color is represented in digital
images is crucial for various applications in image processing, computer vision, and graphics.

Key Concepts in Color Image Representation

• Color Models
• Color Spaces
• Color Channels
• Bit Depth
• Color Conversion

5.1.1. Color Models

• Definition: A color model is a mathematical model describing the way colors can be
represented as tuples of numbers.

Common Color Models:


• RGB (Red, Green, Blue): Most common model used in digital displays.
• CMY/CMYK (Cyan, Magenta, Yellow, Black): Used in color printing.
• HSV (Hue, Saturation, Value): Often used in color selection tools.

Examples:
• RGB Model: A color is represented as a combination of red, green, and blue values,
e.g., (255, 0, 0) for pure red.
• CMYK Model: Used in printing where colors are mixed using four inks, e.g., (0, 1, 1,
0) for pure cyan.

5.1.2. Color Spaces

• Definition: A color space is a specific organization of colors, based on a color model,


that allows for consistent color representation.

Common Color Spaces:


• sRGB: Standard RGB color space used in most digital devices.
• Adobe RGB: Wider color space used in professional photography.
• Pro-Photo RGB: Even wider gamut, used in high-end imaging.

Examples:
• sRGB: Standard color space for web images, ensuring colors look consistent across
different devices.
• Adobe RGB: Preferred for print media because it covers more shades of green and cyan.
5.1.3. Color Channels

• Definition: Each primary color in a color model is represented by a separate channel in


a digital image.

Details:
• In the RGB model, there are three channels: Red, Green, and Blue.
• Each channel is a grayscale image representing the intensity of that color component.

Example:
• An RGB image of a sunset will have three separate matrices for R, G, and B, each
storing intensity values ranging from 0 to 255.

5.1.4. Bit Depth

• Definition: Bit depth refers to the number of bits used to represent the color of a single
pixel.

Common Bit Depths:


• 8bit: 256 levels per channel (standard for most images).
• 16bit: 65,536 levels per channel (used in high dynamic range imaging).
• 24bit: True color, combining three 8bit channels (standard for color images).

Example:
• 8bit per channel RGB image: Each color channel has 256 possible values, leading to
over 16 million possible colors (256 x 256 x 256).

5.1.5. Color Conversion

• Definition: Converting an image from one color space to another.

Common Conversions:
• RGB to Grayscale: Reduces the image to one channel by averaging the RGB values.
• RGB to HSV: Useful for color-based segmentation and filtering.

Example:
• Converting an RGB image to grayscale can be done using a weighted sum of the RGB
values: Grey = 0.2989 * R + 0.5870 * G + 0.1140 * B.

5.2. Detailed Examples

5.2.1. RGB Color Model


• Representation: An RGB image is stored as three 2D arrays corresponding to the red,
green, and blue channels.
Visualization:

import matplotlib.pyplot as plt


import numpy as np

Create a simple RGB image


red_channel = np.zeros((100, 100), dtype=np.uint8)
green_channel = np.zeros((100, 100), dtype=np.uint8)
blue_channel = np.zeros((100, 100), dtype=np.uint8)

red_channel[:50, :] = 255 Upper half is red


green_channel[:, :50] = 255 Left half is green
blue_channel[50:, 50:] = 255 Bottomright quarter is blue

rgb_image = np.stack((red_channel, green_channel, blue_channel), axis=1)

plt.imshow(rgb_image)
plt.title("RGB Color Model Example")
plt.show()

5.2.2. HSV Color Model


• Representation: The HSV model separates color information (hue) from intensity
information (value), making it useful for color filtering.

Conversion:

from skimage.color import rgb2hsv, hsv2rgb

Convert the RGB image to HSV


hsv_image = rgb2hsv(rgb_image)

Visualize the HSV image


plt.imshow(hsv_image)
plt.title("HSV Color Model Example")
plt.show()
6. Intensity Transform Function

6.1.Introduction to Intensity Transform Functions

• Definition: Intensity transform functions, also known as point processing or pointwise


operations, are fundamental techniques in digital image processing that modify the
pixel intensities of an image based on a predefined function.
• Purpose: They are used to enhance, adjust, or manipulate the contrast, brightness, or
overall appearance of images.

6.2.Basic Concepts

• Pixel Intensity: Refers to the brightness or color value of a pixel, typically represented
as a numerical value (e.g., grayscale intensity from 0 to 255).
• Intensity Transform Function: A mapping function (T) that assigns new intensity values
to pixels based on their original values.

6.3.Types of Intensity Transform Functions

6.3.1. Linear Intensity Transformation:


• Description: Simplest form, adjusts contrast and brightness linearly.

Example:

Brightness adjustment T(r) = r + b, where r is the original intensity and b is a constant.

6.3.2. Gamma Correction:


• Purpose: Adjusts image gamma to correct brightness and contrast.

Function:

where c and γ are constants.

• Example: Enhances dark or light areas depending on γ value.

6.3.3. Histogram Equalization:


• Description: Adjusts intensity distribution to enhance contrast.
• Process: Redistributes pixel intensities to achieve a more uniform histogram.
• Application: Improves visibility of details in both bright and dark areas.

6.3.4. Thresholding:
• Purpose: Converts grayscale image into binary image (black and white).
• Method: Pixels are classified as foreground (white) or background (black) based on a
threshold value.
• Example:
6.4.Implementation in Image Processing

• Sequential Processing: Apply intensity transforms pixel-by-pixel across the entire


image.
• Realtime Applications: Used in cameras, video processing, and computer vision
systems for rapid adjustment.

6.5.Impact on Image Quality

• Enhancement: Improves visual quality by adjusting brightness, contrast, or


emphasizing specific features.
• Artistic Effects: Creates stylistic effects or enhances certain colors or details.

6.6.Considerations and Limitations

• Noise Sensitivity: Some transforms may amplify noise.


• Loss of Information: Aggressive transformations can lead to loss of original image
details.

6.7.Applications

• Medical Imaging: Enhancing diagnostic clarity through contrast adjustments.


• Photography: Improving image quality and aesthetics.
• Satellite Imaging: Enhancing visibility of specific features on Earth's surface.
7. Histogram Processing

7.1.Introduction to Histogram Processing

Histogram processing is a crucial technique in the field of digital image processing. It involves
the manipulation of an image's histogram to enhance its visual quality. A histogram represents
the distribution of pixel intensities in an image. By understanding and modifying this
distribution, we can achieve various image enhancement goals, such as improving contrast and
brightness.

7.2.Understanding Histograms

A histogram is a graphical representation that displays the frequency of occurrence of different


intensity levels in an image. It consists of:

• X-axis: Represents the intensity values (ranging from 0 to 255 for an 8bit grayscale
image).
• Y-axis: Represents the frequency (number of pixels) corresponding to each intensity
value.

For a grayscale image, the histogram gives a quick visual insight into the distribution of shades
of grey.

7.3.Types of Histogram Processing

• Histogram Equalization
• Histogram Matching (Specification)

7.3.1. Histogram Equalization

Histogram equalization is a technique used to improve the contrast of an image. This method
spreads out the most frequent intensity values, thereby increasing the global contrast of the
image. It's especially useful for images that are either too dark or too bright.

Steps for Histogram Equalization:

• Compute the Histogram: Calculate the histogram of the input image.


• Compute the Cumulative Distribution Function (CDF): This is the cumulative sum of
the histogram values, normalized to the range of the intensity values (0255).
• Map the Intensity Values: Use the CDF to map the input intensity values to new values,
ensuring a uniform distribution.

Example:
Consider a simple 3x3 grayscale image with the following pixel values:
• The histogram for this image would have high peaks at 50, 100, and 150.
• Calculate the CDF for these intensity values.
• Use the CDF to map the old intensity values to new ones, resulting in a more uniformly
distributed histogram.

7.3.2. Histogram Matching (Specification)

Histogram matching aims to transform the histogram of an input image to match the histogram
of a target image. This technique is useful when we want to give one image the appearance of
another.

Steps for Histogram Matching:

• Compute Histograms: Calculate the histograms for both the input and target images.
• Compute CDFs: Calculate the CDFs for both histograms.
• Map Intensity Values: Create a mapping from the input image's intensity values to the
target image's intensity values using their respective CDFs.

Example:

If we have an input image with a flat histogram and a target image with a bellshaped histogram:

• Compute the CDFs for both histograms.


• Create a mapping function based on these CDFs.
• Apply this mapping to the input image to transform its histogram to match that of the
target image.

7.4.Practical Example

Let's look at a practical example using a simple grayscale image.

Original Image:

Histogram:
100: 3 pixels
150: 3 pixels
200: 3 pixels
Histogram Equalization:

• Compute CDF:
o For 100: CDF = 3/9 = 0.33
o For 150: CDF = 6/9 = 0.67
o For 200: CDF = 9/9 = 1.00

• 2. Map New Intensities:


o For 100: New intensity = 0.33 * 255 ≈ 84
o For 150: New intensity = 0.67 * 255 ≈ 170
o For 200: New intensity = 1.00 * 255 = 255

New Image:

7.5.Visualization and Interpretation

By examining the histograms before and after processing, we can see the impact of histogram
equalization. The original image has distinct peaks, while the processed image has a more
uniform distribution of pixel intensities, resulting in improved contrast.
8. Spatial Filtering

8.1.Introduction to Spatial Filtering

Spatial filtering is a fundamental technique in digital image processing used to enhance or


modify an image. The process involves the manipulation of pixel values in the spatial domain,
where the image is represented as a grid of pixel intensities. Spatial filtering can be used for a
variety of purposes, including noise reduction, edge detection, and image sharpening.

8.2.Basic Concepts

• Spatial Domain: The spatial domain refers to the representation of an image as a


function of two spatial variables, typically x and y. Each point (x, y) in the spatial
domain corresponds to a pixel in the image with a certain intensity value.

• Filter: A filter is a matrix (also called a kernel or mask) that is applied to an image to
produce a new image. The filter is typically smaller than the image and is moved across
the image to apply its effects.

• Convolution: Convolution is the mathematical operation used to apply a filter to an


image. It involves sliding the filter over the image, multiplying the filter values by the
corresponding pixel values, and summing the results to produce a new pixel value.

8.3.Types of Spatial Filters

Spatial filters can be broadly classified into two categories:

• Linear Filters: These filters apply a linear transformation to the pixel values. Common
linear filters include:

o Averaging Filter (Mean Filter): Used for noise reduction by averaging the pixel values
within a neighbourhood.
o Gaussian Filter: A type of averaging filter that gives more weight to the central pixels,
producing a smoother blur.
o Laplacian Filter: Used for edge detection by highlighting areas of rapid intensity
change.

• Non-linear Filters: These filters apply a nonlinear transformation to the pixel values.
Common nonlinear filters include:

o Median Filter: Used for noise reduction by replacing each pixel value with the median
of the neighbouring pixel values. It is particularly effective for removing saltandpepper
noise.
o Max Filter: Replaces each pixel value with the maximum value in the neighborhood.
o Min Filter: Replaces each pixel value with the minimum value in the neighborhood.
8.4.Steps in Spatial Filtering

• Select a Filter: Choose an appropriate filter (kernel) based on the desired effect (e.g.,
smoothing, sharpening, edge detection).

• Define the Neighbourhood: Determine the size of the neighbourhood (e.g., 3x3, 5x5)
that the filter will operate on.

• Apply Convolution: Move the filter across the image, applying the convolution
operation at each pixel position to compute the new pixel value.

• Handle Border Pixels: Decide how to handle the borders of the image where the filter
extends beyond the edge. Common approaches include padding with zeros, replicating
the edge pixels, or wrapping around.

8.5. Examples

• Averaging Filter

An averaging filter smooths an image by averaging the pixel values within a neighbourhood.
For a 3x3 averaging filter, the kernel is:

When applied to an image, the filter computes the average of the pixel values in the 3x3
neighbourhood and assigns this average value to the central pixel.

• Gaussian Filter

A Gaussian filter provides a weighted average of the pixel values in a neighbourhood, with
weights determined by the Gaussian function. For a 3x3 Gaussian filter with a standard
deviation σ, the kernel might look like:

This filter smooths the image while preserving edges better than the simple averaging filter.
• Laplacian Filter

A Laplacian filter detects edges by highlighting areas of rapid intensity change. A common
3x3 Laplacian kernel is:

Applying this filter emphasizes edges and fine details in the image.

• Median Filter

A median filter replaces each pixel value with the median value of the neighbouring pixels.
For a 3x3 neighbourhood, if the pixel values are [10, 20, 30, 40, 50, 60, 70, 80, 90], the median
value is 50. This filter effectively removes salt-and-pepper noise.

8.6.Practical Considerations

• Kernel Size: Larger kernels provide more smoothing but can also blur important details.
The choice of kernel size depends on the specific application and desired outcome.

• Filter Weights: The weights of the filter determine its effect. For example, a Gaussian
filter with higher central weights will preserve more details while smoothing the image.

• Computational Efficiency: Convolution can be computationally intensive, especially


for large images and filters. Efficient algorithms and hardware acceleration can be used
to speed up the process.

• Edge Handling: Proper handling of the image borders is crucial to avoid artifacts.
Padding with zeros, replicating edges, or other methods can be used to address this
issue.
9. Fourier Transforms and Its Properties

9.1.Introduction to Fourier Transforms


The Fourier Transform is a powerful mathematical tool used in digital image processing and
signal processing. It transforms a signal from the time (or spatial) domain into the frequency
domain. This transformation reveals the frequency components of the signal, making it easier
to analyse and process.

9.2.Basic Concepts

• Time Domain vs. Frequency Domain:


o Time Domain (Spatial Domain): Represents a signal (or image) in terms of time (or
spatial coordinates).
o Frequency Domain: Represents the signal in terms of its frequency components.

• Fourier Transform:
For a continuous signal f(t) the Fourier Transform F(ω) is defined as:

For a discrete signal f[n], the Discrete Fourier Transform (DFT) is defined as:

• Inverse Fourier Transform:


For a continuous signal, the Inverse Fourier Transform is:

For a discrete signal, the Inverse Discrete Fourier Transform (IDFT) is:

9.3.Properties of Fourier Transforms

• Linearity:
The Fourier Transform of a sum of signals is the sum of their Fourier Transforms.

If f(t) and g(t) have Fourier Transforms F(ω) and G(ω) respectively, then:

F{af(t)+bg(t)}=aF(ω)+bG(ω)
Example: For f(t)=cos(2πt) and g(t)=sin(2πt) the Fourier Transforms are:

F{cos(2πt)}=π[δ(ω−2π)+δ(ω+2π)]

F{sin(2πt)}=jπ[δ(ω−2π)−δ(ω+2π)]

• Shift:
Shifting a signal in the time domain results in a phase shift in the frequency domain.
If f(t) has a Fourier Transform F(ω), then:

F{f(t−t0)}=F(ω)e−jωt0

Example: For f(t)=e−t2, shifted by t0, the Fourier Transform is

F{e−(t−t0)2}=e−jωt0F{e−t2}
• Scaling:
Scaling a signal in the time domain results in an inverse scaling in the frequency domain.
If F(t) has a Fourier Transform F(ω), then:

1
F{f(at)}=∣𝑎∣ 𝐹(𝜔/𝑎)

Example: For f(t)=e−t2 scaled by a, the Fourier Transform is:

1
F{e−(at)2}= F{e−t2}
∣𝑎∣

• Convolution:
The convolution of two signals in the time domain corresponds to multiplication in the
frequency domain.
If f(t) and g(t) have Fourier Transforms F(ω) and G(ω), then:

F{f(t)∗g(t)}=F(ω)⋅G(ω)

Example: For f(t)=cos(2πt) and g(t)=sin(2πt), the convolution in the time domain is:

F{cos(2πt)∗sin(2πt)}=π[δ(ω−2π)+δ(ω+2π)]⋅jπ[δ(ω−2π)−δ(ω+2π)]

• Multiplication:
Multiplication of two signals in the time domain corresponds to convolution in the frequency
domain.
If f(t) and g(t) have Fourier Transforms F(ω) and G(ω), then:

1
F{f(t)⋅g(t)}= 2π(F∗G)(ω)

Example: For f(t)=cos(2πt) and g(t)=sin(2πt), the multiplication in the time domain is:
• Duality:
The Fourier Transform exhibits a duality property where the roles of the time and frequency
domains can be interchanged.
If f(t) has a Fourier Transform F(ω), then:

F{F(t)}=2πf(−ω)

• Parseval's Theorem:
Parseval's theorem states that the total energy of a signal in the time domain is equal to the total
energy in the frequency domain.
If f(t) has a Fourier Transform F(ω), then:

9.4.Applications

• Signal Analysis:
Fourier Transforms are used to analyse the frequency components of signals, helping
identify periodicities, harmonics, and other characteristics.

• Image Processing:
In image processing, the Fourier Transform is used for tasks such as filtering, image
compression, and edge detection. The 2D Fourier Transform is applied to images to
analyse their frequency content.

• Audio Processing:
In audio processing, the Fourier Transform helps analyse sound signals, detect
frequencies, and perform operations like equalization and noise reduction.

9.5.Examples
Example of Fourier Transform:

Example of Inverse Fourier Transform:


10.Frequency Domain Filters and Hough Transformation

10.1. Introduction

In digital image processing, frequency domain filters and the Hough transformation are
powerful techniques used for different purposes. Frequency domain filters are applied to
manipulate the frequency content of an image, while the Hough transformation is a feature
extraction technique used to detect geometric shapes like lines and circles in an image.

Part 1: Frequency Domain Filters

10.2. Basic Concepts

• Frequency Domain:
o The frequency domain represents an image in terms of its frequency
components rather than its spatial components.
o Each point in the frequency domain corresponds to a specific frequency present
in the image.

• Fourier Transform:
o The Fourier Transform converts an image from the spatial domain to the
frequency domain.
o The Inverse Fourier Transform converts it back to the spatial domain.

• Frequency Domain Filtering:


o Frequency domain filtering involves modifying the frequency components of
an image to achieve desired effects such as blurring, sharpening, or noise
reduction.

10.3. Types of Frequency Domain Filters

• LowPass Filters (LPF):


o Allow lowfrequency components to pass and attenuate highfrequency components.
o Used for blurring and noise reduction.
o Example: Ideal LowPass Filter (ILPF), Gaussian LowPass Filter (GLPF).

• HighPass Filters (HPF):


o Allow highfrequency components to pass and attenuate lowfrequency components.
o Used for edge detection and image sharpening.
o Example: Ideal HighPass Filter (IHPF), Gaussian HighPass Filter (GHPF).

• BandPass Filters (BPF):


o Allow a specific range of frequencies to pass and attenuate others.
o Used to isolate certain frequency ranges.
• BandStop Filters (BSF):
o Attenuate a specific range of frequencies and allow others to pass.
o Used to remove specific frequency components (e.g., periodic noise).

10.4. Steps in Frequency Domain Filtering

• Transform the Image to Frequency Domain:


Use the Fourier Transform to convert the image from the spatial domain to the
frequency domain.

• Apply the Filter:


Design and apply the desired filter in the frequency domain.

• Transform the Image Back to Spatial Domain:


Use the Inverse Fourier Transform to convert the filtered image back to the spatial
domain.

10.5. Examples

• LowPass Filtering:
Consider an image with noise. Applying a Gaussian LowPass Filter can smooth the image and
reduce noise.
The filter function in the frequency domain is:

where D(u,v) is the distance from the origin in the frequency domain and D0 is the cutoff
frequency.

• High-Pass Filtering:
To enhance edges in an image, apply an Ideal High-Pass Filter.
The filter function in the frequency domain is:

where D(u,v) is the distance from the origin and D0 is the cutoff frequency.
Part 2: Hough Transformation

10.6. Basic Concepts

• Purpose:
The Hough transformation is used to detect geometric shapes, such as lines and circles,
in an image.

• Hough Space:
The Hough transformation maps points in the image space to curves in the Hough space
(parameter space).

10.7. Line Detection

• Equation of a Line:
In the Cartesian coordinate system, a line can be represented as y=mx+by = mx + by=mx+b.

In the Hough transformation, it is often represented in polar form: ρ=xcosθ+ysinθ, where ρ is


the perpendicular distance from the origin to the line, and θ is the angle of the line.

• Steps in Line Detection:


Edge Detection: Use an edge detection algorithm (e.g., Canny) to find edge points in the image.

Parameter Space Mapping: For each edge point (x,y), calculate the corresponding (ρ,θ), values
and vote in the accumulator array.
Peak Detection: Identify peaks in the accumulator array, which correspond to potential lines in
the image.

• Example:
Consider an image with several lines. Using the Hough transformation, each edge point votes
for all possible lines passing through it. Peaks in the Hough space indicate the presence of lines.

10.8. Circle Detection

• Equation of a Circle:
o A circle with radius r and centre (a,b) can be represented as (x−a)2+(y−b)2=r2.

• Steps in Circle Detection:


o Edge Detection: Use an edge detection algorithm to find edge points.
o Parameter Space Mapping: For each edge point (x, y) and possible radius r, calculate
the corresponding centre (a, b) and vote in the accumulator array.
o Peak Detection: Identify peaks in the accumulator array, which correspond to potential
circles in the image.
• Example:
o Consider an image with several circles. Using the Hough transformation, each edge
point votes for all possible circles passing through it. Peaks in the Hough space indicate
the presence of circles.

10.9. Practical Considerations

• Computational Complexity:
The Hough transformation can be computationally intensive, especially for large
images and complex shapes. Optimizations and efficient algorithms can be used to
speed up the process.

• Noise Sensitivity:
Frequency domain filtering can help reduce noise before applying the Hough
transformation to improve detection accuracy.

• Parameter Selection:
The choice of filter parameters (e.g., cutoff frequency) and Hough transformation
parameters (e.g., accumulator resolution) can significantly impact the results.
11.Image Noise and Restoration

11.1. Introduction

In digital image processing, noise refers to random variations in the pixel values of an image.
Noise can degrade the quality of an image, making it difficult to analyse and interpret. Image
restoration involves techniques to reduce or eliminate noise, aiming to recover the original,
clean image.

11.2. Types of Image Noise

11.2.1. Gaussian Noise:


• Characterized by a normal distribution of pixel values.
• Commonly caused by thermal noise in sensors.
• The probability density function of Gaussian noise is:

where μ is the mean and σ is the standard deviation.

11.2.2. Salt-and-pepper Noise:


• Appears as randomly occurring white and black pixels.
• Caused by faulty camera sensors, transmission errors, or bit errors in image processing.
• This type of noise is also known as impulse noise.

11.2.3. Poisson Noise:


• Arises due to the discrete nature of photon counting in imaging sensors.
• The noise level is proportional to the square root of the intensity of the signal.

11.2.4. Speckle Noise:


• Common in radar and medical ultrasound imaging.
• Caused by random variations in the return signal due to the coherent nature of the
waves.
• Modelled as multiplicative noise.

11.3. Noise Models

Additive Noise:
The noisy image g(x,y) is the sum of the original image f(x,y) and the noise n(x,y):

g(x, y) = f(x, y) + n(x, y)


Multiplicative Noise:
The noisy image g(x,y) is the product of the original image f(x,y) and the noise n(x,y):
g(x, y) = f(x, y).n(x, y)

11.4. Image Restoration Techniques

• Spatial Domain Filtering: Directly operates on the pixels of the image.

o Mean Filter:
➢ Averages the pixel values in a neighbourhood to smooth the image.
➢ Effective for Gaussian noise but can blur edges.
➢ Kernel example for a 3x3 mean filter:

o Median Filter:
➢ Replaces each pixel value with the median of the pixel values in the neighbourhood.
➢ Effective for salt-and-pepper noise.
➢ Example: For a 3x3 neighbourhood [10, 20, 30, 40, 50, 60, 70, 80, 90], the median is
50.

o Gaussian Filter:
➢ Weighs the pixel values in the neighbourhood according to a Gaussian distribution.
➢ Provides a smoother result than the mean filter.
➢ Kernel example for a 3x3 Gaussian filter:

• Frequency Domain Filtering: Operates on the frequency components of the image.

o Low-Pass Filter (LPF):


➢ Attenuates high frequency components to reduce noise.
➢ Example: Gaussian Low-Pass Filter with cutoff frequency D0:

where D(u,v) is the distance from the origin in the frequency domain.
Wiener Filter:
➢ Minimizes the mean square error between the estimated image and the original image.
➢ Adaptive filter that considers both the local image variance and the noise variance.
➢ Filter function:

where Sf(u,v) is the power spectral density of the original image and Sn(u,v) is the power
spectral density of the noise.

• Restoration Using Image Models: Assumes a model for the degradation and seeks to
invert it.

o Inverse Filtering:
➢ Directly inverts the degradation process.
➢ Suitable when the degradation function is known.
➢ Filter function:
1
H(u,v)= 𝐷(𝑢,𝑣)

where D(u, v) is the degradation function.

o Regularized Filtering:
➢ Extends inverse filtering by incorporating a regularization term to handle noise and
other imperfections.
➢ Balances between fidelity to the degraded image and smoothness of the restored image.
➢ Regularization function:

where D*(u, v) is the complex conjugate of the degradation function, α is the regularization
parameter, and P(u, v) is the Fourier transform of the regularization term.

11.5. Examples

• Gaussian Noise Reduction with Gaussian Filter:


o Original image with Gaussian noise:
g(x,y)=f(x,y)+n(x,y),n(x,y)∼N(0,σ2)

o Apply a Gaussian filter to smooth the noise:


Filtered Image=g(x,y)∗h(x,y)
where h(x, y) is the Gaussian kernel.
• Salt-and-pepper Noise Reduction with Median Filter:
o Original image with salt-and-pepper noise:

o Apply a median filter to remove noise:


Filtered Image=median(g(x−1:x+1,y−1:y+1))

• Speckle Noise Reduction with Wiener Filter:


o Original image with speckle noise:

g(x,y)=f(x,y)⋅n(x,y),n(x,y)∼Multiplicative noise

o Apply a Wiener filter to adaptively reduce noise:

Filtered Image=H(u,v)⋅G(u,v)

where H(u, v) is the Wiener filter function and G(u, v) is the Fourier transform
of the noisy image.

*******

You might also like