Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Digital Image Processing

Uploaded by

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

Digital Image Processing

Uploaded by

Mohd Jamil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

MODULE 1

Digital Image Processing - Introduction : Motivation and Prespective Applications, comonents of image
Processing System Fundamentals: Element of Visual Perception. A Simple Image Model, Sampling and
Quantization;Image Enhancement in Spatial Domain Introduction; Basic Gray Level Functions:
Piecewise-Linear Transformation Functions - Contrast Stretching
Arithmetic/Logic Operations-Image Subtraction, Image Averaging: Basics of Spatial Filtering:
Smoothing - Mean filter, Ordered Statistic Filter; Sharpening - The Laplacian:

Digital Image Processing - Introduction


1. Motivation and Perspective:

● Definition:
○ Digital image processing (DIP) deals with manipulating digital images using a digital
computer.
○ It focuses on developing a computer system capable of processing images efficiently.
● Applications:
○ DIP finds applications in various fields:
1. Gamma Ray Imaging:
■ Used in nuclear medicine and astronomical observations.
2. X-Ray Imaging:
■ Provides X-rays of the human body for medical diagnosis.
3. Ultraviolet Band:
■ Applied in lithography, industrial inspection, microscopy, and lasers.
4. Visual and Infrared Band:
■ Used in remote sensing applications.
5. Microwave Band:
■ Utilized for radar imaging.

2. Components of Image Processing System:

1. Image Sensors:
○ These physical devices are sensitive to the energy radiated by the object we wish to
image.
○ They capture the raw data from the scene.
2. Specialized Image Processing Hardware:
○ Includes digitizers (convert analog signals to digital form).
○ Performs primitive operations (e.g., arithmetic, logical) on images.
3. Computer:
○ A general-purpose computer (ranging from PCs to supercomputers) depending on the
application.
○ Specialized computers may be used for dedicated applications.
4. Software:
○ Specialized modules perform specific tasks.
○ Well-designed packages allow user-written code and module integration.
5. Mass Storage:
○ Essential for image processing applications.
○ An image of size 1024 x 1024 pixels with 8-bit intensity per pixel requires 1 megabyte of
storage space (uncompressed).

Example:
Suppose we’re building an image processing system for medical X-ray images. Let’s apply these
concepts:

1. Motivation:
○ Develop an efficient system to enhance X-ray images for accurate diagnosis.
○ Apply algorithms to remove noise and improve contrast.
2. Components:
○ Image sensors capture X-ray energy.
○ Specialized hardware digitizes and processes the raw data.
○ A powerful computer runs image processing algorithms.
○ Software modules enhance image quality.
○ Mass storage stores the processed X-ray images.

Piecewise-Linear Transformation Functions - Contrast


Stretching
1. Contrast Stretching:

● Motivation:
○ Images often suffer from low contrast due to improper illumination, non-linear response of
sensors, or a limited dynamic range.
○ Contrast stretching aims to enhance the dynamic range of gray levels in an image.
○ It improves visibility and reveals details that might be hidden in low-contrast regions.
● Mathematical Formulation:
○ Given an input intensity (r), the output intensity (s) is computed using a piecewise-linear
transformation:
■ For (0 \leq r < a): [ s = l \cdot r ]
■ For (a \leq r < b): [ s = m \cdot (r - a) + v ]
■ For (b \leq r < L-1): [ s = n \cdot (r - b) + w ]
○ Here:
■ (L) represents the total number of intensity levels (e.g., 256 for an 8-bit image).
■ (l), (m), and (n) are slopes.
■ (a) and (b) define the range of intensities to be stretched.
■ (v) and (w) are offsets.
● Example:
○ Suppose we have a grayscale image with intensity values ranging from 0 to 255.
○ We want to stretch the intensity levels from 50 to 200.
○ Using the contrast stretching formula, we calculate the new intensity values for each
pixel.
Original Intensity ((r)) New Intensity ((s))

0 0

50 0

100 85

150 170

200 255

● The resulting image will have improved contrast, with a wider range of intensity levels.

Histogram Equalization
● Purpose:
○ Histogram equalization is a fundamental technique in image processing.
○ It aims to improve the contrast of an image by redistributing the intensity levels.
○ The goal is to achieve a uniform histogram, making the image visually more appealing.
● Mathematical Formulation:
○ Given an input intensity (r), the output intensity (s) is computed using the cumulative
distribution function (CDF) of the original image: [ s = T® = \frac{{L-1}}{{N}}
\sum_{k=0}^{r} h(k) ]
○ Where:
■ (L) represents the total number of intensity levels (e.g., 256 for an 8-bit image).
■ (N) is the total number of pixels in the image.
■ (h(k)) is the histogram value at intensity level (k).
● Example:
○ Suppose we have a grayscale image with the following histogram:

Intensity Level ((k)) Histogram Value ((h(k)))

0 10

1 15

2 20

… …

255 5

- We compute the CDF:

\[ CDF(k) = \sum_{i=0}^{k} h(i) \]

- Using the formula, we calculate the new intensity values for each pixel.

Local Enhancement
● Motivation:
1. Local enhancement techniques focus on improving specific regions of an image.
2. They adaptively adjust pixel intensities based on local context.
3. Useful for enhancing details in specific areas.
● Methods:
1. Local Histogram Equalization:
■ Apply histogram equalization to small local neighborhoods.
■ Enhances contrast locally.
2. Adaptive Contrast Stretching:
■ Stretch the intensity range based on local statistics (mean, standard deviation).
■ Useful for non-uniform illumination correction.
3. Local Gamma Correction:
■ Adjust gamma locally to enhance or suppress details.
■ Useful for medical imaging and low-light photography.

Example:
Suppose we have a medical X-ray image. Let’s apply these techniques:

1. Histogram Equalization:
○ Enhance the overall contrast of the entire image.
○ Achieve a uniform histogram.
2. Local Enhancement:
○ Apply local histogram equalization to specific regions (e.g., bone structures).
○ Improve visibility of subtle features.

Arithmetic/Logic Operations
Arithmetic and logic operations play a crucial role in image processing. These operations manipulate pixel
values to achieve specific goals. Here are some key concepts:

1. Addition (Image Summation):


○ Given two images, A and B, pixel-wise addition results in a new image C where each
pixel value is the sum of the corresponding pixels from A and B:
○ C(x, y) = A(x, y) + B(x, y)
2. Subtraction (Image Difference):
○ Similar to addition, pixel-wise subtraction yields a new image D:
○ D(x, y) = A(x, y) - B(x, y)
3. Logical AND, OR, and NOT:
○ These operations are applied to binary images (where each pixel is either 0 or 1).
○ For example, the logical AND of two binary images A and B results in a new image E:
○ E(x, y) = A(x, y) \text{ AND } B(x, y)

Image Subtraction
Image subtraction is useful for detecting changes between two images. For instance, it can highlight
moving objects in video surveillance. The formula for image subtraction is as follows:

\text{Result}(x, y) = \text{Image1}(x, y) - \text{Image2}(x, y)

Image Averaging
Image averaging is a simple yet effective technique for noise reduction. It involves taking the average of
pixel values within a local neighborhood. Here’s how it works:

1. Mean Filter (Box Filter):


○ The mean filter replaces each pixel value with the average of its neighboring pixels.
○ For a 3x3 neighborhood centered at pixel (x, y):
○ \text{Filtered}(x, y) = \frac{1}{9} \sum_{i=-1}^{1} \sum_{j=-1}^{1} \text{Image}(x+i, y+j)
2. Ordered Statistic Filter (Median Filter):
○ The median filter replaces each pixel value with the median of its neighboring pixels.
○ It is robust against outliers and preserves edges.
○ For the same 3x3 neighborhood:
○ \text{Filtered}(x, y) = \text{Median}(\text{Image}(x-1:x+1, y-1:y+1))

Sharpening - The Laplacian


Sharpening enhances edges and fine details in an image. The Laplacian operator detects rapid intensity
changes. Here’s the Laplacian formula:

1. Laplacian Operator:
○ For a grayscale image I(x, y):
○ \text{Laplacian}(x, y) = \nabla^2 I(x, y) = \frac{\partial^2 I}{\partial x^2} + \frac{\partial^2
I}{\partial y^2}
2. Discrete Laplacian:
○ Approximated using finite differences:
○ \text{Laplacian}(x, y) = I(x+1, y) + I(x-1, y) + I(x, y+1) + I(x, y-1) - 4I(x, y)

Example:
Let’s consider a small 3x3 grayscale image with the following pixel values:

[ 50, 60, 70 ]

[ 55, 80, 65 ]

[ 75, 40, 90 ]

1. Mean Filter (3x3):


○ Apply the mean filter to smooth the image:
○ \text{Filtered}(1, 1) = \frac{1}{9} \sum_{i=-1}^{1} \sum_{j=-1}^{1} \text{Image}(1+i, 1+j) =
67.22
2. Median Filter (3x3):
○ Apply the median filter:
○ \text{Filtered}(1, 1) = \text{Median}([40, 50, 55, 60, 65, 70, 75, 80, 90]) = 65
3. Laplacian:
○ Compute the Laplacian at pixel (1, 1):
○ \

MODULE 2
Image Enhancement in Frequency Domain Fourier Transform NAd the Frequency Domain & Image
Restoration - Basic Filtering in Frequency Domain: Filters, Low- pass , High Pass, Correspondence
Between Filtering in Spatial and frequency domain, Smoothing Frequency Domain Filters- Gaussian Low
pass Filters Sharpening frequency Domain FIlters-Gaussian Highpass Filters; Homomorphic Filtering
Image Restoratin: A model of restoration Process, Noise Models, Restoration in the presence of Noise,
only Spatial Filtering-Mean Filters: Arithmetic Mean filter, Geometric Mean Filters, Order Stastic Filters -
Median Filter, Max and Min filters; Periodic Noise Reduction by Frequency Domain Filtering - Bandpass
Filters; Minimum Mean square Error Restoration

Image Enhancement in the Frequency Domain


Image enhancement techniques aim to improve the visual quality of images by manipulating their
frequency components. The frequency domain provides a powerful framework for achieving this. Here are
the key concepts:

1. Fourier Transform:
○ The Fourier Transform decomposes an image into its frequency components.
○ For a 2D grayscale image I(x, y), the continuous Fourier Transform is given by:
○ F(u, v) = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} I(x, y) e^{-j2\pi(ux + vy)} \, dx \, dy
○ The inverse Fourier Transform reconstructs the image from its frequency components:
○ I(x, y) = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} F(u, v) e^{j2\pi(ux + vy)} \, du \, dv
2. Frequency Domain Filtering:
○ Enhancements can be applied by modifying the Fourier Transform.
○ High-pass filters emphasize edges and fine details, while low-pass filters reduce noise
and smooth the image.
○ Example: To enhance high-frequency components (edges), multiply the Fourier
Transform by a high-pass filter function.

Image Restoration
Image restoration aims to recover the original image from a degraded or noisy version. Here’s how it
works:

1. Degradation Model:
○ The observed image G(x, y) is related to the original image F(x, y) through a degradation
process:
○ G(x, y) = H(x, y) \ast F(x, y) + N(x, y)
■ H(x, y): Degradation function (blur kernel)
■ N(x, y): Additive noise
2. Inverse Filtering:
○ The goal is to estimate F(x, y) from G(x, y).
○ Inverse filtering attempts to invert the degradation process:
○ \hat{F}(u, v) = \frac{G(u, v)}{H(u, v)}
■ Note: Division in the frequency domain can amplify noise.
3. Wiener Filtering:
○ Wiener filtering balances noise reduction and image restoration:
○ \hat{F}(u, v) = \frac{H^*(u, v) G(u, v)}{|H(u, v)|^2 + K}
■ K: Regularization parameter (trade-off between noise and restoration)

Example:
Let’s consider a simple example:

1. Original Image:
○ A grayscale image with sharp edges (e.g., an image of text).
○ Fourier Transform: F(u, v)
2. Degradation:
○ Blurring due to motion (e.g., camera shake during capture).
○ Degradation function: H(x, y) (blur kernel)
○ Additive noise: N(x, y)
3. Observed Image:
○ G(x, y) = H(x, y) \ast F(x, y) + N(x, y)
4. Restoration:
○ Apply inverse filtering or Wiener filtering to estimate F(x, y) from G(x, y).

Filters in the Frequency Domain


Filters in the frequency domain manipulate the frequency components of an image. Here are the key
concepts:

1. Low-Pass Filter:
○ A low-pass filter allows low-frequency components (such as smooth variations) to pass
through while attenuating high-frequency components (such as noise or fine details).
○ The ideal low-pass filter in the frequency domain is defined as:
○ H(u, v) = \begin{cases} 1, & \text{if } D(u, v) \leq D_0 \\ 0, & \text{otherwise} \end{cases}
■ (D(u, v)): Distance from the origin in the frequency domain

(D_0): Cutoff frequency (determines the balance between smoothing and
preservation of details)
2. High-Pass Filter:
○ A high-pass filter enhances high-frequency components (such as edges or rapid intensity
changes) while suppressing low-frequency components.
○ The ideal high-pass filter is complementary to the low-pass filter:
○ H(u, v) = 1 - \text{Low-Pass Filter}(u, v)

Correspondence Between Spatial and Frequency Domain


Filtering
● The convolution operation in the spatial domain corresponds to element-wise multiplication in the
frequency domain.
● Given an image (I(x, y)) and its Fourier Transform (F(u, v)):
○ Spatial domain filtering: (I’(x, y) = I(x, y) \ast H(x, y))
○ Frequency domain filtering: (F’(u, v) = F(u, v) \cdot H(u, v))

Smoothing Frequency Domain Filters


Smoothing filters reduce noise and blur an image. Let’s explore two common smoothing filters:

1. Gaussian Filter:
○ The Gaussian filter is widely used for smoothing.
○ Its frequency domain representation is given by:
○ H(u, v) = e^{-\frac{D(u, v)^2}{2\sigma^2}}
■ (\sigma): Standard deviation (controls the amount of smoothing)
2. Butterworth Filter:
○ The Butterworth filter provides a smooth transition between passband and stopband.
○ Its frequency domain representation is:
○ H(u, v) = \frac{1}{1 + \left(\frac{D(u, v)}{D_0}\right)^{2n}}
■ (D_0): Cutoff frequency
■ (n): Order (higher values yield sharper transitions)

Example:
Let’s consider a simple 4x4 grayscale image with pixel values:

[ 50, 60, 70, 80 ]

[ 55, 65, 75, 85 ]

[ 70, 80, 90, 100 ]

[ 75, 85, 95, 105 ]


1. Low-Pass Filtering:
○ Apply a Gaussian low-pass filter with (\sigma = 1):
■ Compute the Fourier Transform (F(u, v)).
■ Multiply (F(u, v)) by the Gaussian filter in the frequency domain.
■ Inverse Fourier Transform to obtain the filtered image.
2. High-Pass Filtering:
○ Apply a Butterworth high-pass filter with (D_0 = 10) and (n = 2):
■ Compute the Fourier Transform (F(u, v)).
■ Multiply (F(u, v)) by the Butterworth filter in the frequency domain.
■ Inverse Fourier Transform to obtain the high-pass filtered image.

Gaussian Low-Pass Filters


Gaussian low-pass filters are commonly used for image smoothing and noise reduction. They attenuate
high-frequency components while preserving low-frequency information. Here’s how they work:

1. Gaussian Filter Function:


○ The frequency domain representation of a Gaussian low-pass filter is given by:
○ H(u, v) = e^{-\frac{D(u, v)^2}{2\sigma^2}}
■ (D(u, v)): Distance from the origin in the frequency domain
■ (\sigma): Standard deviation (controls the amount of smoothing)
2. Filter Application:
○ Multiply the Fourier Transform of the image by the Gaussian filter.
○ Inverse Fourier Transform to obtain the filtered image.

Sharpening Frequency Domain Filters


Sharpening filters enhance edges and fine details in an image. Let’s explore one such filter:

1. Laplacian Filter:
○ The Laplacian operator detects rapid intensity changes.
○ Its frequency domain representation is:
○ H(u, v) = -4\pi^2(u^2 + v^2)
○ Apply the Laplacian filter to emphasize edges.

Gaussian High-Pass Filters


Gaussian high-pass filters accentuate high-frequency components while suppressing low-frequency
information. Here’s the concept:

1. Complementary to Gaussian Low-Pass:


○ The Gaussian high-pass filter is complementary to the Gaussian low-pass filter.
○ Its frequency domain representation is:
○ H(u, v) = 1 - e^{-\frac{D(u, v)^2}{2\sigma^2}}
Homomorphic Filtering
Homomorphic filtering is useful for enhancing images with varying illumination conditions. It balances the
intensity variations. Here’s how it works:

1. Logarithmic Transformation:
○ Take the logarithm of the original image:
○ \text{LogImage}(x, y) = \log(1 + \text{Image}(x, y))
2. Apply Low-Pass Filter:
○ Use a low-pass filter (e.g., Gaussian) to suppress high-frequency noise.
3. Inverse Logarithmic Transformation:
○ Exponentiate the filtered result:
○ \text{EnhancedImage}(x, y) = e^{\text{FilteredLogImage}(x, y)} - 1

Example:
Let’s consider a simple 3x3 grayscale image with pixel values:

[ 50, 60, 70 ]

[ 55, 80, 65 ]

[ 75, 40, 90 ]

1. Gaussian Low-Pass Filtering:


○ Apply a Gaussian filter with (\sigma = 1):
■ Compute the Fourier Transform (F(u, v)).
■ Multiply (F(u, v)) by the Gaussian filter in the frequency domain.
■ Inverse Fourier Transform to obtain the smoothed image.
2. Laplacian Sharpening:
○ Compute the Laplacian filter in the frequency domain:
○ H(u, v) = -4\pi^2(u^2 + v^2)
○ Multiply (F(u, v)) by the Laplacian filter.
○ Inverse Fourier Transform to obtain the sharpened image.
3. Gaussian High-Pass Filtering:
○ Compute the Gaussian high-pass filter:
○ H(u, v) = 1 - e^{-\frac{D(u, v)^2}{2\sigma^2}}
○ Multiply (F(u, v)) by the Gaussian high-pass filter.
4. Homomorphic Filtering:
○ Apply the logarithmic transformation to the original image.
○ Use a low-pass filter (e.g., Gaussian) on the log-transformed image.
○ Inverse log-transform the filtered result.

Image Restoration: A Model of Restoration Process


Image restoration aims to recover the original image from a degraded or noisy version. Here’s the model
of the restoration process:

1. Degradation Model:
○ The observed image G(x, y) is related to the original image F(x, y) through a degradation
process:
○ G(x, y) = H(x, y) \ast F(x, y) + N(x, y)
■ H(x, y): Degradation function (blur kernel)
■ N(x, y): Additive noise
2. Inverse Filtering:
○ The goal is to estimate F(x, y) from G(x, y).
○ Inverse filtering attempts to invert the degradation process:
○ \hat{F}(u, v) = \frac{G(u, v)}{H(u, v)}
■ Note: Division in the frequency domain can amplify noise.
3. Wiener Filtering:
○ Wiener filtering balances noise reduction and image restoration:
○ \hat{F}(u, v) = \frac{H^*(u, v) G(u, v)}{|H(u, v)|^2 + K}
■ K: Regularization parameter (trade-off between noise and restoration)

Noise Models
Noise in images can arise from various sources, such as sensor imperfections, transmission, or
digitization. Common noise models include:

1. Additive White Gaussian Noise (AWGN):


○ The most prevalent noise model.
○ It follows a Gaussian distribution with zero mean and a specified variance.
2. Salt-and-Pepper Noise:
○ Occurs randomly, adding white and black pixels (salt and pepper) to the image.

Restoration in the Presence of Noise


Restoring images with noise involves trade-offs between noise reduction and detail preservation. Key
steps include:

1. Noise Estimation:
○ Estimate the noise level in the observed image.
○ Common methods include statistical analysis or visual inspection.
2. Regularization:
○ Regularization techniques (e.g., Tikhonov regularization) balance noise reduction and
image fidelity.

Only Spatial Filtering - Mean Filter


Spatial filtering directly operates on pixel values within a local neighborhood. The mean filter is a simple
spatial filter for noise reduction:
1. Mean Filter (Box Filter):
○ Replaces each pixel value with the average of its neighboring pixels.
○ For a 3x3 neighborhood centered at pixel (x, y):
○ \text{Filtered}(x, y) = \frac{1}{9} \sum_{i=-1}^{1} \sum_{j=-1}^{1} \text{Image}(x+i, y+j)

Example:
Let’s consider a small 3x3 grayscale image with the following pixel values:

[ 50, 60, 70 ]

[ 55, 80, 65 ]

[ 75, 40, 90 ]

1. Mean Filtering (3x3):


○ Apply the mean filter to smooth the image:
■ Compute the average of the 3x3 neighborhood around each pixel.
■ Example: (\text{Filtered}(1, 1) = \frac{1}{9} \sum_{i=-1}^{1} \sum_{j=-1}^{1}
\text{Image}(1+i, 1+j) = 67.22)

Arithmetic Mean Filter


The arithmetic mean filter is a simple spatial filter used for smoothing (blurring) an image. It replaces each
pixel value with the average of its neighboring pixels within a local window. Here’s how it works:

1. Filter Operation:
○ For a square neighborhood of size (N \times N), centered at pixel ((x, y)):
○ \text{Filtered}(x, y) = \frac{1}{N^2} \sum_{i=-k}^{k} \sum_{j=-k}^{k} \text{Image}(x+i, y+j)
○ (k = \frac{N-1}{2})

Geometric Mean Filter


The geometric mean filter is another type of smoothing filter. Instead of averaging pixel values, it
computes the geometric mean within the local window:

1. Filter Operation:
○ Similar to the arithmetic mean filter, but using the geometric mean:
○ \text{Filtered}(x, y) = \left(\prod_{i=-k}^{k} \prod_{j=-k}^{k} \text{Image}(x+i,
y+j)\right)^{\frac{1}{N^2}}

Order Statistic Filters


Order statistic filters are based on ranking pixel values within a neighborhood. Let’s explore two common
order statistic filters:

1. Median Filter:
○ The median filter replaces each pixel value with the median of its neighboring pixels.
○ It is robust against outliers and preserves edges.
○ For the same square neighborhood:
○ \text{Filtered}(x, y) = \text{Median}(\text{Image}(x-k:x+k, y-k:y+k))
2. Max and Min Filters:
○ The max filter replaces each pixel value with the maximum value in the neighborhood.
○ The min filter replaces each pixel value with the minimum value in the neighborhood.

Example:
Let’s consider a small 3x3 grayscale image with the following pixel values:

[ 50, 60, 70 ]

[ 55, 80, 65 ]

[ 75, 40, 90 ]

1. Arithmetic Mean Filtering (3x3):


○ Apply the arithmetic mean filter:
■ Compute the average of the 3x3 neighborhood around each pixel.
■ Example: (\text{Filtered}(1, 1) = \frac{1}{9} \sum_{i=-1}^{1} \sum_{j=-1}^{1}
\text{Image}(1+i, 1+j) = 67.22)
2. Geometric Mean Filtering (3x3):
○ Apply the geometric mean filter:
■ Compute the geometric mean within the same 3x3 neighborhood.
■ Example: (\text{Filtered}(1, 1) = \left(50 \cdot 60 \cdot 70 \cdot 55 \cdot 80 \cdot
65 \cdot 75 \cdot 40 \cdot 90\right)^{\frac{1}{9}} = 64.68)
3. Median Filtering (3x3):
○ Apply the median filter:
■ Sort the pixel values in the 3x3 neighborhood and choose the middle value.
■ Example: (\text{Filtered}(1, 1) = \text{Median}([40, 50, 55, 60, 65, 70, 75, 80, 90])
= 65)
4. Max and Min Filtering (3x3):
○ Compute the maximum and minimum values within the same 3x3 neighborhood.
■ Max: (\text{Filtered}(1, 1) = 90)
■ Min: (\text{Filtered}(1, 1) = 40)

Periodic Noise Reduction by Frequency Domain Filtering


Bandpass Filters

Bandpass filters are designed to selectively allow a certain range of frequencies to pass through while
attenuating others. They are particularly useful for reducing periodic noise in images. Here’s how they
work:

1. Ideal Bandpass Filter:


○ The ideal bandpass filter in the frequency domain is defined as:
○ H(u, v) = \begin{cases} 1, & \text{if } D_1 \leq D(u, v) \leq D_2 \\ 0, & \text{otherwise}
\end{cases}
■ (D(u, v)): Distance from the origin in the frequency domain
■ (D_1): Lower cutoff frequency
■ (D_2): Upper cutoff frequency
2. Filter Application:
○ Multiply the Fourier Transform of the image by the bandpass filter.
○ Inverse Fourier Transform to obtain the filtered image.

Minimum Mean Square Error Restoration

Minimum Mean Square Error (MMSE) restoration aims to estimate the original image from a degraded
version by minimizing the mean square error. Here’s the process:

1. Degradation Model:
○ The observed image G(x, y) is related to the original image F(x, y) through a degradation
process:
○ G(x, y) = H(x, y) \ast F(x, y) + N(x, y)
■ H(x, y): Degradation function (blur kernel)
■ N(x, y): Additive noise
2. MMSE Estimation:
○ Estimate the original image using MMSE:
○ \hat{F}(u, v) = \frac{H^*(u, v) G(u, v)}{|H(u, v)|^2 + \frac{1}{S_N(u, v)}}
■ (S_N(u, v)): Power spectral density of the noise

Example:
Let’s consider a simple 3x3 grayscale image with the following pixel values:

[ 50, 60, 70 ]

[ 55, 80, 65 ]

[ 75, 40, 90 ]
1. Bandpass Filtering:
○ Apply an ideal bandpass filter with (D_1 = 10) and (D_2 = 20):
■ Compute the Fourier Transform (F(u, v)).
■ Multiply (F(u, v)) by the bandpass filter in the frequency domain.
■ Inverse Fourier Transform to obtain the filtered image.
2. MMSE Restoration:
○ Assume a known degradation function (H(x, y)) (e.g., motion blur).
○ Estimate the original image using MMSE:
■ Compute the power spectral density of the noise (S_N(u, v)).
■ Apply the MMSE formula to estimate (\hat{F}(u, v)).

MODULE 3
Colour & morphological Image processing & registration: color Fundamentals: color Models - Converting
Colors to different models : Color Transformation Smoothing and Sharpening, Color Segmentation
Morphological Image processing : Introduction, Logic Operations involving Binary Images, Dilation and
Erosion, Opening and Closing, Morphological Algorithms - Boundary Extraction, Region Filling Extraction
of Connected Components, Convex hull, Thinning , Thickening,

Color Fundamentals
Color Models

1. RGB (Red-Green-Blue):
○ Represents colors using combinations of red, green, and blue channels.
○ Each channel ranges from 0 to 255.
○ Example: RGB(255, 0, 0) represents pure red.
2. CMY (Cyan-Magenta-Yellow):
○ Used in subtractive color mixing (e.g., printing).
○ Complementary to RGB.
○ Example: CMY(0, 255, 255) represents cyan.
3. HSV (Hue-Saturation-Value):
○ Describes colors based on perceptual attributes:
■ Hue: Dominant color (0 to 360 degrees).
■ Saturation: Intensity of color (0 to 100%).
■ Value: Brightness (0 to 100%).

Converting Colors to Different Models

1. RGB to HSV:
○ Convert RGB to normalized values (0 to 1).
○ Compute hue, saturation, and value.
2. HSV to RGB:
○ Compute red, green, and blue channels from HSV values.

Color Transformation
Smoothing and Sharpening

1. Smoothing:
○ Apply filters (e.g., Gaussian) to reduce noise and blur colors.
○ Example: Convolve the RGB channels with a 3x3 Gaussian kernel.
2. Sharpening:
○ Enhance edges and details.
○ Example: Use Laplacian or unsharp masking.

Color Segmentation
1. K-Means Clustering:
○ Cluster similar colors into groups.
○ Example: Segment an image into sky, grass, and buildings.

Example:
Let’s consider an RGB image with the following pixel values (each channel):

Red: [ 255, 0, 128 ]


Green: [ 64, 192, 32 ]
Blue: [ 0, 128, 255 ]

1. RGB to HSV:
○ Convert RGB to normalized values (0 to 1):
■ Red: (1, 0, 0)
■ Green: (0.25, 0.75, 0.125)
■ Blue: (0, 0.5, 1)
○ Compute hue, saturation, and value.
2. HSV to RGB:
○ Compute red, green, and blue channels from HSV values.
3. Smoothing:
○ Apply a 3x3 Gaussian filter to each channel.
4. Sharpening:
○ Enhance edges using Laplacian or unsharp masking.
5. Color Segmentation:
○ Use K-means clustering to segment the image into color regions.

Introduction to Morphological Image Processing


Morphological image processing focuses on analyzing and manipulating the shape and structure of
objects within an image. It is particularly useful for binary (black-and-white) images. Here are the key
concepts:

1. Binary Images:
○ Binary images consist of only two intensity levels (usually 0 and 1).
○ Objects of interest are typically represented by white pixels (1), while the background is
represented by black pixels (0).

Logic Operations Involving Binary Images


1. Logical AND:
○ Combines two binary images by taking the minimum value at each pixel location.
○ Example: If we have two binary images (A) and (B), the logical AND operation results in a
new image (C) where (C(x, y) = \min(A(x, y), B(x, y))).
2. Logical OR:
○ Combines two binary images by taking the maximum value at each pixel location.
○ Example: If we have two binary images (A) and (B), the logical OR operation results in a
new image (C) where (C(x, y) = \max(A(x, y), B(x, y))).
3. Logical NOT:
○ Inverts the pixel values of a binary image.
○ Example: If we have a binary image (A), the logical NOT operation results in a new image
(B) where (B(x, y) = 1 - A(x, y)).

Dilation and Erosion


1. Dilation:
○ Expands the boundaries of white regions (foreground) in a binary image.
○ It is achieved by sliding a structuring element (usually a small binary matrix) over the
image and setting the center pixel to 1 if any of the overlapping pixels are 1.
○ Mathematically:
○ D(A, B) = \{ (x, y) \mid B \text{ is completely contained in } A \text{ when centered at } (x,
y) \}
■ (A): Original binary image
■ (B): Structuring element
2. Erosion:
○ Shrinks the boundaries of white regions in a binary image.
○ It is achieved by sliding the structuring element over the image and setting the center
pixel to 1 only if all overlapping pixels are 1.
○ Mathematically:
○ E(A, B) = \{ (x, y) \mid B \text{ is completely contained in } A \text{ when centered at } (x,
y) \}
■ (A): Original binary image
■ (B): Structuring element

Opening and Closing


1. Opening:
○ Combines erosion followed by dilation.
○ Removes small noise and fills gaps in white regions.
○ Mathematically:
○ \text{Opening}(A, B) = D(E(A, B), B)
2. Closing:
○ Combines dilation followed by erosion.
○ Fills small holes and smooths the boundaries of white regions.
○ Mathematically:
○ \text{Closing}(A, B) = E(D(A, B), B)

Example:
Let’s consider a simple 5x5 binary image with the following pixel values (1 for white, 0 for black):

[ 0, 0, 0, 0, 0 ]
[ 0, 1, 1, 1, 0 ]
[ 0, 1, 1, 1, 0 ]
[ 0, 1, 1, 1, 0 ]
[ 0, 0, 0, 0, 0 ]

1. Logical AND:
○ Combine this image with another binary image using logical AND.
○ Example: If we have another binary image with all 1s, the result will be the same as the
original image.
2. Logical OR:
○ Combine this image with another binary image using logical OR.
○ Example: If we have another binary image with all 0s, the result will be the same as the
original image.
3. Logical NOT:
○ Invert the pixel values of this binary image.

Boundary Extraction
1. Boundary of a Binary Object:
○ The boundary of a binary object (white region) is the set of pixels that have at least one
black neighbor.
○ It represents the contour of the object.
2. Boundary Extraction Algorithm:
○ Given a binary image (A):
■ Compute the boundary by subtracting the eroded image from the original image:
■ \text{Boundary}(A) = A - E(A)
■ (E(A)): Erosion of (A)

Region Filling
1. Region Filling Algorithm:
○ Given a seed point ((x, y)) inside a white region:
■ Initialize an empty set (R).
■ Add ((x, y)) to (R).
■ While there are neighboring white pixels:
■ Add them to (R).
■ The set (R) represents the filled region.

Extraction of Connected Components


1. Connected Components:
○ Connected components are disjoint regions of white pixels in a binary image.
○ Each component corresponds to an object or part of an object.
2. Connected Component Labeling Algorithm:
○ Assign a unique label to each connected component:
■ Use depth-first search or breadth-first search to traverse the white pixels.
■ Label each pixel with the component number.

Convex Hull
1. Convex Hull:
○ The convex hull of a set of points is the smallest convex polygon that encloses all the
points.
○ Useful for shape analysis and pattern recognition.
2. Convex Hull Algorithm:
○ Given a set of points:
■ Compute the convex hull using algorithms like Graham’s scan or Jarvis march.

Thinning and Thickening


1. Thinning:
○ Reduces the thickness of white regions while preserving connectivity.
○ Removes pixels to achieve a skeleton-like representation.
○ Example: Zhang-Suen thinning algorithm.
2. Thickening:
○ Increases the thickness of white regions.
○ Adds pixels to expand the regions.
○ Example: Dilation followed by erosion.

Example:
Let’s consider a simple 5x5 binary image with the following pixel values (1 for white, 0 for black):

[ 0, 0, 0, 0, 0 ]
[ 0, 1, 1, 1, 0 ]
[ 0, 1, 0, 1, 0 ]
[ 0, 1, 1, 1, 0 ]
[ 0, 0, 0, 0, 0 ]

1. Boundary Extraction:
○ Compute the boundary of the white region.
2. Region Filling:
○ Given a seed point inside the white region, find the filled region.
3. Connected Components:
○ Label the connected components in the image.
4. Convex Hull:
○ Compute the convex hull of the white pixels.
5. Thinning:
○ Apply a thinning algorithm to reduce the thickness of the white regions.
6. Thickening:
○ Apply dilation followed by erosion to expand the white regions.

Image Registration: Introduction


Image registration is the process of aligning two or more images to a common coordinate system. It is
essential for various applications, such as medical imaging, remote sensing, and computer vision. Here
are the key concepts:

1. Motivation:
○ Combine information from multiple images.
○ Correct geometric distortions.
○ Enable comparison and analysis.
2. Geometric Transformation:
○ Transform one image to match the other.
○ Common transformations include translation, rotation, scaling, and shearing.

Geometric Transformation: Plane-to-Plane Transformation


1. Affine Transformation:
○ An affine transformation preserves parallel lines and ratios of distances.
○ It includes translation, rotation, scaling, and shearing.
○ Mathematically: [ \begin{bmatrix} x’ \ y’ \ 1 \end{bmatrix} = \begin{bmatrix} a & b & t_x \ c
& d & t_y \ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \ y \ 1 \end{bmatrix} ]
■ ((x, y)): Original coordinates
■ ((x’, y’)): Transformed coordinates
■ (a, b, c, d): Scaling, rotation, and shearing parameters
■ (t_x, t_y): Translation parameters

Stereo Imaging Algorithms to Establish Correspondence


1. Stereo Vision:
○ Stereo imaging uses two or more cameras to capture the same scene from different
viewpoints.
○ The goal is to establish correspondence between points in the left and right images.
2. Correspondence Problem:
○ Given two stereo images, find matching points.
○ Algorithms include:
■ Block Matching: Compare local windows.
■ Graph Cuts: Optimize energy functions.
■ Semi-Global Matching: Consider global consistency.

Algorithms to Recover Depth


1. Depth Map:
○ A depth map represents the distance of each pixel from the camera.
○ It provides 3D information from stereo images.
2. Disparity Map:
○ The disparity map indicates pixel shifts between stereo images.
○ Disparity is inversely proportional to depth.
3. Depth Recovery Algorithms:
○ Triangulation: Use geometry to compute depth.
○ Stereo Matching: Estimate disparity and convert to depth.
○ Structured Light: Project patterns to infer depth.

Example:
Let’s consider two stereo images of a simple scene. We want to register them and recover depth
information.

1. Affine Transformation:
○ Apply an affine transformation to align the images.
○ Example: Rotate the right image by 10 degrees.
2. Stereo Correspondence:
○ Use block matching to find corresponding points.
○ Compute the disparity map.
3. Depth Recovery:
○ Convert disparity to depth using triangulation: [ \text{Depth} = \frac{B \cdot
f}{\text{Disparity}} ]
■ (B): Baseline (distance between cameras)
■ (f): Focal length

MODULE 4
Segmentation & obejct Recognition Segmentation : introduction, Region Extraction, pixel-Based approach
, Multi level Thresholding, Local Thresholding Segmentation: Region based Approach , Edge Operators
pater Fitting Approach, Edge Linking and Edge Following, Edge Elements,
Feature Extraction Resperestantion: Boundary based Description, Regionbased Description, relationship,
Object recognition: Deterministic Methods, Clustering, Statistical Classification, Syntactic Recognition,
tree Search, Graph Matching

Segmentation: Introduction
1. What is Segmentation?:
○ Segmentation is the process of dividing an image into meaningful regions or objects.
○ It aims to group pixels with similar characteristics together.

Region Extraction
1. Region-Based Segmentation:
○ Divide an image into regions based on pixel intensity, color, or texture.
○ Common methods include:
■ Thresholding: Assign pixels to regions based on intensity thresholds.
■ Region Growing: Start with seed pixels and expand regions based on similarity
criteria.

Pixel-Based Approach
1. Pixel-Based Segmentation:
○ Assign each pixel to a specific class or region.
○ Example: Assign pixels as foreground or background.

Multi-Level Thresholding
1. Multi-Level Thresholding:
○ Divide an image into more than two regions using multiple intensity thresholds.
○ Mathematically:
■ Given an image (I(x, y)) and (N) thresholds ({T_1, T_2, \ldots, T_N}): [ R_i = {(x,
y) \mid I(x, y) \text{ belongs to region } i} ]
■ (R_i): Region corresponding to threshold (T_i)

Local Thresholding
1. Local Thresholding:
○ Adaptively compute thresholds for different image regions.
○ Example: Otsu’s method computes local thresholds based on local histograms.

Example:
Let’s consider a grayscale image with intensity values:
[ 50, 60, 70, 80, 90 ]
[ 55, 65, 75, 85, 95 ]
[ 60, 70, 80, 90, 100 ]
[ 65, 75, 85, 95, 105 ]
[ 70, 80, 90, 100, 110 ]

1. Multi-Level Thresholding (3 regions):


○ Set thresholds: (T_1 = 70) and (T_2 = 90).
○ Regions:
■ (R_1): Pixels with intensity (\leq 70)
■ (R_2): Pixels with intensity (> 70) and (\leq 90)
■ (R_3): Pixels with intensity (> 90)
2. Local Thresholding:
○ Compute local thresholds for each 3x3 neighborhood using Otsu’s method.
○ Assign pixels to regions based on local thresholds.

Segmentation: Region-Based Approach


1. Region-Based Segmentation:
○ In region-based segmentation, we group pixels into meaningful regions based on their
similarity.
○ The goal is to partition an image into coherent regions that correspond to objects or parts
of objects.

Edge Operators
1. Edge Detection:
○ Edges represent significant changes in intensity or color within an image.
○ Edge detection algorithms highlight these transitions.
2. Gradient Operators:
○ Compute the gradient (rate of change) of intensity in an image.
○ Common gradient operators:
■ Sobel: Computes gradients in both horizontal and vertical directions.
■ Prewitt: Similar to Sobel but with different weightings.

Pattern Fitting Approach


1. Pattern Fitting:
○ Fit geometric shapes (lines, circles, ellipses) to image regions.
○ Example: Hough transform for detecting lines.

Edge Linking and Edge Following


1. Edge Linking:
○ Connect edge segments to form longer contours.
○ Use criteria like proximity and orientation.
2. Edge Following:
○ Trace along edges to form complete contours.
○ Example: Freeman chain code for encoding contours.

Edge Elements
1. Canny Edge Detector:
○ Combines gradient information and non-maximum suppression.
○ Detects edges with sub-pixel accuracy.

Example:
Let’s consider a grayscale image with intensity values:

[ 50, 60, 70, 80, 90 ]


[ 55, 65, 75, 85, 95 ]
[ 60, 70, 80, 90, 100 ]
[ 65, 75, 85, 95, 105 ]
[ 70, 80, 90, 100, 110 ]

1. Edge Detection:
○ Apply the Sobel operator to compute gradients.
○ Highlight edges by thresholding the gradient magnitude.
2. Pattern Fitting:
○ Detect straight lines using the Hough transform.
○ Fit lines to the detected edge segments.
3. Edge Linking and Following:
○ Connect adjacent edge pixels to form contours.
○ Use Freeman chain code to encode the contours.

Boundary-Based Description
1. Boundary Extraction:
○ The boundary of an object represents its contour or outer edge.
○ It is obtained by detecting significant intensity changes or gradients.
○ Common methods:
■ Edge Detection: Sobel, Prewitt, Canny operators.
■ Contour Tracing: Freeman chain code, Moore-Neighbor tracing.
2. Boundary Descriptors:
○ Quantify the shape of the boundary.
○ Examples:
■ Perimeter: Total length of the boundary.
■ Curvature: Rate of change of direction along the boundary.

Region-Based Description
1. Region Properties:
○ Describe regions based on pixel values within the object.
○ Common properties:
■ Area: Number of pixels in the region.
■ Centroid: Geometric center of the region.
■ Compactness: Ratio of perimeter to area.
2. Region Descriptors:
○ Quantify the characteristics of the entire region.
○ Examples:
■ Euler Number: Topological property indicating the number of holes.
■ Moments: Statistical measures of pixel intensities.

Relationship Between Boundary and Region


1. Boundary-Region Duality:
○ The boundary and region are complementary.
○ A closed boundary encloses a region, and vice versa.
2. Shape Context:
○ Describes the relationship between boundary points and region properties.
○ Captures the spatial distribution of boundary points around the centroid.

Example:
Let’s consider a binary image with a simple object:

[ 0, 0, 0, 0, 0 ]
[ 0, 1, 1, 1, 0 ]
[ 0, 1, 0, 1, 0 ]
[ 0, 1, 1, 1, 0 ]
[ 0, 0, 0, 0, 0 ]

1. Boundary Extraction:
○ Compute the boundary using contour tracing.
○ Calculate the perimeter.
2. Region-Based Description:
○ Compute the area of the object.
○ Find the centroid (average position of white pixels).
3. Shape Context:
○ Measure the curvature at different points along the boundary.
○ Compare the distribution of boundary points with the centroid.

Deterministic Methods
1. Template Matching:
○ Compares a template (small image) with regions of the larger image.
○ Measures similarity using correlation or sum of squared differences.
○ Example:
■ Given a template of a stop sign, find all occurrences in a traffic scene.
2. Feature Matching:
○ Detects distinctive features (corners, edges) in both template and target images.
○ Matches features based on descriptors (e.g., SIFT, SURF).
○ Example:
■ Match keypoints between two images for object recognition.

Clustering
1. K-Means Clustering:
○ Groups similar data points into clusters.
○ Example:
■ Cluster color histograms of images to recognize objects.

Statistical Classification
1. Bayesian Decision Theory:
○ Classifies objects based on probability distributions.
○ Uses Bayes’ theorem to estimate class probabilities.
○ Example:
■ Given features (e.g., texture, color), classify fruits as apples or oranges.

Syntactic Recognition
1. Syntactic Pattern Recognition:
○ Models patterns using formal grammars or automata.
○ Analyzes structural relationships.
○ Example:
■ Recognize license plates using context-free grammars.

Tree Search
1. Decision Trees:
○ Hierarchical structure for classification.
○ Each node represents a decision based on features.
○ Example:
■ Decide whether an email is spam or not based on keywords.

Graph Matching
1. Graph Matching Algorithms:
○ Match graphs (representing objects) based on topology.
○ Example:
■ Match hand-drawn sketches to predefined shapes.

Example:
Let’s consider an image recognition scenario:

1. Template Matching:
○ Given a template of a cat’s face, find all occurrences in a collection of cat images.
2. Feature Matching:
○ Detect keypoints (corners) in the template and target images.
○ Match keypoints based on descriptors (e.g., SIFT).
3. K-Means Clustering:
○ Cluster color histograms of images into categories (e.g., animals, vehicles).
4. Bayesian Decision Theory:
○ Estimate probabilities of an image belonging to different classes (e.g., dog, car).
5. Syntactic Recognition:
○ Define a grammar for recognizing handwritten digits (0-9).
6. Decision Trees:
○ Build a decision tree to classify images as indoor or outdoor scenes.
7. Graph Matching:
○ Match graphs representing social networks to identify similar users.

You might also like