Erosion in Digital Image Processing
Erosion in Digital Image Processing
Definition:
Erosion is a morphological operation in digital image processing that reduces the size of foreground
objects in a binary image by eroding away their boundaries using a structuring element. It is
commonly used to simplify shapes and remove noise.
o If all pixels under the structuring element match the foreground (value 1), the pixel
remains foreground.
3. Effect:
Mathematical Formula:
Given an input image AAA and structuring element BBB:
Where BzB_zBz is the structuring element shifted to the position zzz, and Bz⊆AB_z \subseteq ABz⊆A
means BzB_zBz must completely fit within the foreground of AAA.
Example:
1. Input Image:
Copy code
11110
11110
11110
00000
Copy code
111
111
1
111
Copy code
11100
11100
11100
00000
Applications:
Advantages:
Definition:Edge detection is a technique used in digital image processing to identify and locate sharp
discontinuities (edges) in an image. These edges typically represent significant changes in intensity,
which correspond to boundaries of objects.
Key Points:
1. Noise Reduction: Smooth the image using filters (e.g., Gaussian filter) to reduce noise.
2
Methods of Edge Detection:
o Sobel Operator: Uses two masks (horizontal and vertical) to compute intensity
gradients.
Example:
Horizontal mask:
-1 0 1
-2 0 2
-1 0 1
Vertical mask:
diff
-1 -2 -1
0 0 0
1 2 1
Applications:
1. Object detection.
2. Image segmentation.
3
Advantages:
Definition:
Pattern matching is a technique used to locate specific patterns or objects within an image. It
involves comparing a predefined template (pattern) to regions of an image to find the best match.
Key Points:
2. Search Mechanism:
o Slide the template over the image (using a sliding window approach).
3. Matching Metrics:
o Correlation: Measures similarity between the template and the image region.
1. Pixel-Based Matching: Compares the pixel intensities directly between the template and
image.
2. Feature-Based Matching: Extracts features such as edges, corners, or key points and
matches these features.
o Examples: SIFT (Scale-Invariant Feature Transform), ORB (Oriented FAST and Rotated
BRIEF).
4
3. Correlation-Based Matching:
4. Template Matching:
o A common approach where the template is moved across the image to find regions
with maximum similarity.
Applications:
1. Object Detection: Locating specific objects in images, such as faces, cars, or symbols.
Advantages:
Definition:
Morphological algorithms are image processing techniques based on the shape and structure of
objects in binary or grayscale images. They are widely used for preprocessing, feature extraction, and
shape analysis by applying operations using a structuring element.
1. Structuring Element: A predefined shape (e.g., square, rectangle, circle) used to probe and
modify the image.
2. Set Theory: Morphological operations are based on set theory, where objects in an image
are represented as sets of pixels.
1. Erosion:
5
o Shrinks objects by fitting the structuring element.
2. Dilation:
3. Opening:
o Removes small objects or noise while preserving the shape of larger objects.
4. Closing:
1. Boundary Extraction:
2. Hit-or-Miss Transform:
3. Thinning:
4. Thickening:
5. Pruning:
6. Morphological Gradient:
6
Applications of Morphological Algorithms
5. Medical Imaging: Analyzes biological shapes and structures (e.g., cells, tissues).
Definition:
Thresholding is a simple and effective technique for image segmentation, used to separate objects
(foreground) from the background in an image. It converts a grayscale image into a binary image by
selecting a threshold value and assigning pixel intensities above and below this value to different
categories.
Key Points
1. Purpose: To simplify the image for analysis by reducing it to a binary representation where:
2. Threshold Value (TTT): A scalar value used to differentiate between object and background.
Types of Thresholding
1. Global Thresholding:
2. Adaptive Thresholding:
3. Otsu’s Method:
7
o A global, automatic thresholding technique.
o Finds the threshold value that minimizes the within-class variance or maximizes the
between-class variance of pixel intensities.
4. Multi-Level Thresholding:
o Divides the image into multiple classes using more than one threshold value.
o Used in scenarios where the image has more than two intensity levels.
Steps in Thresholding
1. Convert Image to Grayscale: Thresholding works on intensity values, so the input image
must be grayscale.
3. Apply the Threshold: Compare each pixel intensity with TTT and assign the corresponding
binary value (0 or 1).
4. Generate Binary Image: The resulting image contains only two intensity levels.
Applications
Advantages
Limitations
3. Edge Loss: Sharp details and edges may be lost in binary conversion.
4. Complex Images: Ineffective for images with overlapping objects or multiple intensity levels.
8
Q)Elements of Visual Perception (15 Marks)
Visual perception refers to the process through which we interpret and understand visual stimuli in
the environment. It is a complex mechanism involving various elements that work together to
recognize shapes, colors, depth, and motion.
o Role: It interacts with objects, creating reflections, shadows, and contrasts that the
human eye perceives.
2. Color Perception:
o Role: Helps differentiate objects and understand their properties (e.g., ripeness of
fruit).
o Role: Contours and boundaries help distinguish objects from the background.
o Key Mechanisms:
▪ Edge detection.
▪ Contour integration.
4. Depth Perception:
o Cues:
9
5. Motion Perception:
o Mechanisms:
1. Sensation: Light enters the eye and stimulates photoreceptor cells (rods and cones).
3. Processing: Signals are processed in the retina and transmitted to the brain via the optic
nerve.
4. Interpretation: The brain (primarily the visual cortex) interprets signals to form coherent
images.
Image Sampling and Quantization are fundamental processes in converting a continuous image
(analog) into a digital image.
1. Image Sampling
• Definition: Sampling refers to selecting specific points (pixels) from a continuous image to
represent it digitally.
• Key Idea: Determines the spatial resolution of the image (number of pixels in width and
height).
• Process:
• Effect: Higher sampling rates (more pixels) result in better image quality, while lower rates
can cause loss of details.
10
2. Image Quantization
• Definition: Quantization is the process of mapping the continuous range of pixel intensity
values into a limited set of discrete levels.
• Key Idea: Determines the number of grayscale or color levels (bit depth).
• Process:
o Example: In an 8-bit image, intensity values range from 0 (black) to 255 (white).
• Effect: Higher bit depth provides smoother images with more detail, while lower bit depth
causes visible banding and loss of quality.
Both must be appropriately chosen to balance image quality and storage requirements.
Applications
Gray-scale Morphology is a branch of mathematical morphology that deals with processing and
analyzing images where pixel values (gray levels) represent intensity rather than binary values (black
or white). Unlike binary morphology, which deals with simple foreground and background
distinctions, gray-scale morphology operates on images with continuous intensity levels, allowing for
more nuanced analysis of image structures.
o It is applied to the image by sliding it over the image pixels (like a filter).
2. Gray-Scale Operations:
11
o These operations manipulate the intensity of the image based on the relationship
between the structuring element and the image pixels.
o The two primary operations in gray-scale morphology are dilation and erosion, but
they differ from their binary counterparts because they involve pixel intensity rather
than binary values.
1. Gray-Scale Erosion:
o Definition: Reduces the intensity of pixels in the image based on the minimum value
of the neighborhood defined by the structuring element.
o Process: For each pixel, the minimum pixel value in the region defined by the
structuring element is chosen.
o Effect: It "shrinks" the bright regions of an image (intensities), often removing small
details or noise.
2. Gray-Scale Dilation:
o Definition: Increases the intensity of pixels based on the maximum value in the
neighborhood defined by the structuring element.
o Process: For each pixel, the maximum pixel value in the region defined by the
structuring element is selected.
o Effect: It "expands" the bright regions, making objects in the image larger and filling
gaps in them.
1. Opening:
2. Closing:
o Definition: The reverse of opening, used to fill small holes and gaps in an image.
12
o Process: It is a combination of dilation followed by erosion.
3. Top-hat Transform:
o Process: The result of subtracting the result of opening from the original image.
4. Black-hat Transform:
o Definition: Used to extract dark spots or regions that are smaller than their
surrounding areas.
o Process: The result of subtracting the original image from the result of closing.
Region-based segmentation is an image segmentation technique that divides an image into regions
that share similar properties, such as color, intensity, or texture. Unlike edge-based segmentation
methods that focus on identifying boundaries between different regions, region-based methods
work by grouping together pixels with similar characteristics to form homogeneous regions.
Region-based segmentation is widely used in various applications such as medical imaging, remote
sensing, and object recognition because it can provide more accurate and meaningful results
compared to edge-based methods, especially in images with noisy or unclear boundaries.
1. Region Homogeneity:
o The segmentation process aims to group adjacent pixels with similar features into
regions.
o The most common criteria for homogeneity are intensity or color similarity.
2. Region Growing:
o Process:
1. Start with an initial "seed" pixel, which is chosen based on certain criteria
(e.g., pixel intensity).
13
2. Expand the region by adding neighboring pixels that satisfy the homogeneity
criterion.
3. Repeat the process for all pixels until no more can be added.
o Challenges:
1. Region Growing:
o Description: Starts with a set of seed points (or initial regions) and grows the region
by adding neighboring pixels that are similar in intensity or color.
o Process:
o Description: This method divides the image into a set of initial regions (typically the
whole image) and then progressively splits them into smaller regions or merges
them into larger ones.
o Process:
14
3. Watershed Algorithm:
o Process:
▪ The image is treated as a landscape with hills and valleys (where intensity
values are higher in "hills" and lower in "valleys").
▪ The algorithm "floods" the valleys starting from a set of initial seed points
(markers).
1. Medical Imaging:
o Used in segmenting organs, tumors, or tissues from medical scans like MRI or CT
scans. Accurate segmentation helps in diagnosis, treatment planning, and surgical
navigation.
2. Remote Sensing:
o Applied in satellite and aerial imagery to detect and classify features like water
bodies, urban areas, vegetation, and land cover types.
3. Object Recognition:
o Helps in detecting and isolating objects in an image, which can then be recognized or
tracked in various applications, including robotics and autonomous vehicles.
4. Image Compression:
o Used to segment an image into regions with similar textures, which can then be
compressed efficiently.
Spatial Filtering is a technique in image processing that involves modifying an image by applying a
filter or mask to each pixel based on its neighbors. The process uses a matrix (also called a kernel or
filter) that is slid across the image to perform operations like blurring, sharpening, edge detection,
and noise removal. Spatial filters are applied directly to the spatial domain of an image and are
integral for enhancing or extracting specific features.
15
1. Image and Filter Representation:
o Image: A digital image is represented as a matrix of pixel values, where each element
in the matrix corresponds to a pixel in the image.
o Filter (Kernel): A filter is a small matrix (often 3x3, 5x5, or 7x7) that is applied to the
image matrix. Each element in the filter represents a weight that is used to modify
the corresponding pixel in the image.
o Correlation: Similar to convolution, but the filter is not flipped before being applied.
It is computationally simpler but results in the same effect as convolution for
symmetric filters.
3. Kernel (Filter) Types: Filters come in various shapes and sizes, depending on the desired
image enhancement effect. Some common types of filters are:
o Linear Filters: The output pixel is a weighted average of the surrounding pixels.
Common examples include:
▪ Gaussian Filter: A weighted average filter that gives more importance to the
central pixel and less to surrounding pixels based on a Gaussian distribution.
▪ Median Filter: Replaces each pixel with the median value in its
neighborhood, useful for noise reduction.
▪ Max/Min Filters: Replaces each pixel with the maximum or minimum value
in the neighborhood, often used for detecting bright or dark regions.
1. Smoothing Filters:
o Purpose: These filters reduce noise or fine details in the image, leading to a blurred
or smoothed effect.
o Examples:
▪ Mean Filter: Computes the average of all the pixels in the neighborhood. It is
useful for removing random noise.
16
▪ Process: A 3x3 window is moved over the image, and each pixel in
the window is replaced by the average of all pixel values in the
window.
▪ Gaussian Filter: Similar to the mean filter, but it uses a Gaussian distribution
to assign more weight to the central pixel, making the blur effect smoother.
▪ Process: The filter matrix contains values derived from the Gaussian
function, and the window averages pixels based on this weighted
function.
2. Sharpening Filters:
o Purpose: These filters enhance the edges in an image, making objects and
boundaries more distinct.
o Examples:
o Examples:
▪ Process: The Sobel filter uses two kernels to compute the gradient of
the image in the x and y directions and combines them to highlight
edges.
▪ Prewitt Filter: Similar to the Sobel filter, used for edge detection by
emphasizing horizontal and vertical edges.
1. Choose the Filter: Depending on the task, select an appropriate filter. For example, use a
mean filter for noise removal, a Sobel filter for edge detection, or a Gaussian filter for
smoothing.
17
2. Apply the Filter: Slide the filter over the image, starting from the top-left corner. For each
position, compute the sum of the pixel values multiplied by the corresponding filter weights.
3. Generate the Output: The resulting pixel values from the convolution are placed in a new
image, which is the filtered version of the original.
1. Noise Reduction:
o Spatial filtering, especially using filters like mean or median filters, is used to remove
noise from images. It can smooth out random noise and help in tasks like medical
image analysis or satellite imagery.
2. Image Enhancement:
o Filters like sharpening and contrast enhancement are used to make the image more
visually appealing or improve details, especially in object detection tasks.
Image sharpening is a technique used to enhance the edges and fine details in an image by
increasing the contrast between adjacent pixels. It is commonly used to make an image clearer,
especially when it appears blurry or lacks distinct edges. While sharpening is often achieved using
spatial domain filters, it can also be performed in the frequency domain.
In the frequency domain, images are represented by their frequency components, where low
frequencies correspond to smooth, uniform areas and high frequencies correspond to sharp
transitions, such as edges and fine details. By manipulating these frequency components, sharpness
can be enhanced.
1. Fourier Transform:
o The Fourier Transform (FT) is a mathematical operation that converts an image from
the spatial domain (pixel values) into the frequency domain (frequency
components). This allows us to view the image as a sum of sinusoidal waves with
different frequencies.
o The result of applying the Fourier transform is a frequency spectrum, where the low
frequencies correspond to the smooth parts of the image, and the high frequencies
correspond to the edges and finer details.
where f(x,y)f(x, y)f(x,y) is the pixel value at location (x,y)(x, y)(x,y), and F(u,v)F(u, v)F(u,v) is the
frequency representation of the image.
18
2. Inverse Fourier Transform:
o After modifying the frequency components (e.g., sharpening), the Inverse Fourier
Transform (IFT) is used to convert the modified frequency representation back into
the spatial domain (image).
o The first step is to convert the image from the spatial domain to the frequency
domain using the Fourier Transform. This results in a complex-valued frequency
representation of the image.
▪ Ideal High-Pass Filter: A simple filter that passes frequencies above a certain
cutoff frequency and blocks those below it.
4. Image Sharpening:
o The sharpened image is generated by adding the high-pass filtered image to the
original image. This enhances the high-frequency (edge) components and makes the
image appear sharper.
where I(x,y)I(x, y)I(x,y) is the original image, H(u,v)H(u, v)H(u,v) is the high-pass filter in the frequency
domain, and F(u,v)F(u, v)F(u,v) is the Fourier transform of the image.
19
5. Inverse Fourier Transform:
o After applying the high-pass filter, the Inverse Fourier Transform (IFT) is performed
on the modified frequency representation to obtain the sharpened image in the
spatial domain.
1. Input Image: Start with an image that may have blurred details or low contrast.
2. Fourier Transform: Convert the image into the frequency domain using the Fourier
Transform.
3. Filter Design: Choose an appropriate high-pass filter, such as ideal, Gaussian, or Butterworth,
based on the sharpening requirement.
4. Apply Filter: Multiply the Fourier-transformed image by the high-pass filter to enhance high-
frequency components.
5. Inverse Fourier Transform: Convert the filtered frequency-domain image back into the
spatial domain using the Inverse Fourier Transform.
6. Sharpened Image: The resulting image will have enhanced edges and finer details.
1. Medical Imaging: Enhancing fine details in medical images like CT scans and MRI scans to
highlight regions of interest (e.g., tumors or blood vessels).
2. Satellite Imaging: Sharpening satellite images to improve the clarity of objects and features
on the Earth's surface.
3. Remote Sensing: Enhancing edges and details in remote sensing images for better
interpretation of terrain, vegetation, and man-made structures.
4. Computer Vision: Improving the quality of images for object detection, recognition, and
tracking.
5. Photography: Enhancing image sharpness to make images appear clearer, particularly when
dealing with out-of-focus or blurred images.
Dilation is a local operation that involves a structuring element (also called a kernel) that is applied
to the image. The structuring element is typically a small shape, such as a square, circle, or rectangle,
that slides over the image to process the pixels.
20
• Operation: Dilation adds pixels to the boundaries of the objects in the image.
• Result: It expands the white areas (foreground) and can fill small holes or gaps in objects.
In simple terms, for each pixel in the image, the structuring element is placed over the pixel and the
pixel value is set to the maximum value of the underlying pixels (foreground). This operation
effectively enlarges the boundaries of foreground objects.
For a given binary image III and a structuring element SSS, the dilation of III by SSS is defined as:
Where:
• (S)z(S)_z(S)z denotes the translation of the structuring element SSS at location zzz of the
image.
• ∩\cap∩ represents the intersection, and the result of the operation is the set of all locations
where the structuring element overlaps with at least one foreground pixel in III.
2. Slide the structuring element over the image: For each pixel in the input image, the
structuring element is centered on the pixel, and the operation is applied.
3. Set new pixel value: If any part of the structuring element overlaps with a white pixel
(foreground), the center pixel of the structuring element is set to white. Otherwise, it
remains black.
4. Repeat for all pixels: This process is repeated for all pixels in the image, and the output is a
dilated version of the image.
Example of Dilation
Consider the following example where the binary image III consists of white pixels (1) and black
pixels (0):
Copy code
00000
21
01100
01100
00000
Copy code
010
111
010
When dilation is applied, the white regions (1's) in the original image are expanded by the
structuring element. This will enlarge the existing white regions in the image. The output image
would look like:
Copy code
01110
11111
11111
01110
As shown, the white regions have expanded, and small gaps in the objects have been filled.
Applications of Dilation
1. Noise Removal: Dilation can help in removing small holes or gaps within the foreground
objects, making objects more connected and complete.
2. Object Enlargement: Dilation can be used to enlarge the size of objects in an image, which is
useful in tasks like object detection and recognition.
3. Closing Small Holes: It helps in closing small holes within an object, which can improve the
quality of the detected objects.
4. Skeletonization and Shape Analysis: In shape analysis, dilation is often used in combination
with other operations (like erosion) to detect and analyze the boundaries of shapes or
objects.
5. Image Reconstruction: Dilation can help reconstruct an image after certain transformations
like erosion or noise removal.
22
Q)Fields that use Digital Image Processing
Digital Image Processing (DIP) is used in a wide range of fields to extract, manipulate, and analyze
images for various applications. Some key fields that use Digital Image Processing are:
1. Medical Imaging
• Applications: MRI, CT scans, X-rays, ultrasound, and other medical imaging techniques use
image processing to enhance image quality, detect abnormalities, and assist in diagnoses.
2. Remote Sensing
• Applications: Image processing is used to analyze satellite or aerial images for land mapping,
environmental monitoring, and disaster management.
• Examples: Forest cover analysis, flood detection, urban planning, agriculture monitoring, and
soil analysis.
3. Computer Vision
• Applications: This field aims to enable machines to interpret and understand visual data,
such as objects and scenes in images or videos.
• Examples: Object recognition, face detection, motion tracking, autonomous vehicles (self-
driving cars), and gesture recognition.
4. Robotics
• Applications: In robotics, digital image processing helps robots to navigate, avoid obstacles,
and interact with their environment.
• Examples: Visual SLAM (Simultaneous Localization and Mapping), object manipulation, path
planning, and interaction with humans or objects.
• Applications: Image processing techniques are used for surveillance, face recognition, and
monitoring suspicious activities in real-time.
• Examples: CCTV surveillance, biometric systems (fingerprint, iris, and face recognition), and
video surveillance analysis.
• Applications: In film, gaming, and digital media, image processing is used for enhancing
visual quality, animation, special effects, and real-time video processing.
7. Forensic Science
• Applications: In forensic analysis, digital image processing is used to enhance images, detect
alterations, and examine evidence.
23
• Examples: Enhancing low-resolution crime scene photos, detecting tampered images, facial
recognition for identification, and analyzing fingerprints.
8. Astronomy
• Applications: Image processing is used to enhance astronomical images and extract valuable
information from space images captured by telescopes and spacecraft.
• Examples: Analysis of celestial bodies, detection of galaxies, star classification, and analysis
of satellite images of planets and moons.
9. Agriculture
• Applications: Digital image processing helps in monitoring crops, assessing soil health, and
managing agricultural resources.
• Examples: Crop health monitoring, disease detection, pest identification, and precision
farming using drones and satellite images.
• Examples: Visual inspection for defects in products, robotic assembly lines, and automated
sorting systems based on image recognition.
• Applications: Image processing is used to convert scanned documents into editable text,
identify handwriting, and digitize paper-based information.
• Examples: Deforestation monitoring, water body analysis, and land-use change detection.
• Applications: GIS uses image processing to analyze spatial data, map topography, and extract
features from geographical images.
• Examples: Terrain analysis, mapping roads and rivers, and monitoring urban expansion.
• Applications: Image processing is used in educational tools for visualizing data, analyzing
student behavior, and creating interactive learning resources.
24
• Applications: Image processing is used to inspect fabric quality, pattern recognition, and
design analysis.
• Examples: Defect detection in fabrics, color matching, and pattern recognition for automatic
design creation.
The Discrete Fourier Transform (DFT) is a mathematical technique used to transform a signal from its
original domain (often time or space) into the frequency domain. It is one of the most important
tools in digital signal processing (DSP), allowing us to analyze and manipulate the frequency content
of a discrete signal.
The DFT takes a finite sequence of equally spaced samples of a signal and transforms it into a
sequence of complex numbers, which represent the amplitudes and phases of sinusoidal
components of the signal at various frequencies.
For a given discrete signal x[n]x[n]x[n], where n=0,1,2,...,N−1n = 0, 1, 2, ..., N-1n=0,1,2,...,N−1, the
DFT X[k]X[k]X[k] is given by the formula:
Where:
• kkk represents the index of the frequency component (ranging from 0 to N−1N-1N−1).
1. Time Domain to Frequency Domain: The DFT converts a signal from the time domain (where
we observe the signal in terms of amplitude over time) to the frequency domain (where we
observe the signal in terms of its frequency components). This is crucial in various fields like
signal processing, audio analysis, image processing, etc.
2. Complex Numbers: The output of the DFT, X[k]X[k]X[k], is typically a complex number. The
real part represents the amplitude of the cosine wave at the corresponding frequency, and
the imaginary part represents the amplitude of the sine wave at that frequency.
3. Frequency Resolution: The DFT gives the frequency content of the signal, with each
X[k]X[k]X[k] corresponding to a specific frequency. The resolution of the frequency
25
components depends on the number of samples NNN. A larger NNN gives better frequency
resolution.
4. Symmetry: For real-valued input sequences, the DFT exhibits conjugate symmetry, meaning
the magnitude of X[k]X[k]X[k] is symmetric, and the phase is antisymmetric.
5. Periodicity: The DFT is periodic, meaning the frequency components repeat every NNN
samples. This is due to the periodic nature of the complex exponentials used in the DFT
calculation.
The Fast Fourier Transform (FFT) is an optimized algorithm for calculating the DFT more efficiently.
The DFT computation has a time complexity of O(N2)O(N^2)O(N2), while the FFT reduces it to
O(NlogN)O(N \log N)O(NlogN), making it much faster for large datasets. The FFT is widely used in
signal processing, image analysis, audio compression, and many other fields.
Properties of DFT
1. Linearity: The DFT is a linear operation, meaning the DFT of a sum of signals is the sum of
the DFTs of the individual signals.
2. Shift: Shifting a signal in the time domain corresponds to a linear phase shift in the frequency
domain.
3. Convolution: The DFT of the convolution of two signals is the pointwise product of their
DFTs.
4. Parseval’s Theorem: This theorem relates the total energy in the time domain to the total
energy in the frequency domain:
Applications of DFT
1. Signal Processing: DFT is widely used to analyze and filter signals in communications, audio
processing, and speech recognition.
2. Audio and Speech Processing: In music and speech, DFT is used to extract frequency
components (like pitch, tone) for sound enhancement, compression, and recognition.
26