Module 3
1. Morphology:
● Morphology is a technique in image processing that deals with the shape
and structure of objects in an image.
● It is mostly used on binary images, but it can also be applied to grayscale
images.
● All morphological operations use a small pattern called a Structuring
Element (SE).
● The SE decides how the operation will affect the image.
● Common SE shapes include square, disk, cross, etc.
● Morphology helps in noise removal, filling gaps, extracting boundaries,
and performing shape analysis.
(a) Erosion
● Erosion is a basic morphological operation that reduces or shrinks the
foreground regions in an image.
● When we perform erosion, a small pattern called a Structuring Element
(SE) is slid over the image.
● The SE checks whether the object fits completely inside its shape at every
position.
● If even one pixel under the SE does not satisfy the condition, the central
pixel is eroded or removed.
● Because of this strict rule, erosion makes objects smaller and removes
thin or weak parts of them.
Effects of Erosion
● Removes small white noise particles.
● Makes thick objects thinner.
● Disconnects two objects that touch each other.
● Shrinks boundaries smoothly.
Example:
If there is a small white dot in a black background (noise), erosion will remove
it because the SE cannot fit on it completely.
(b) Dilation
● Dilation is the opposite of erosion.
● Instead of shrinking objects, it expands and grows the white
(foreground) regions.
● The structuring element moves over the image, and if any one pixel
under the SE is white, the central pixel becomes white.
● Thus, dilation adds more white pixels around the object, making it appear
larger and more connected.
Effects of Dilation
● Thickens object boundaries.
● Fills small holes inside objects.
● Connects small gaps between objects.
● Makes objects appear larger.
Example
● If there is a thin or broken line, dilation increases its thickness and
connects the broken parts.
● This makes the line clearer and easier to detect in further processing.
(c) Opening (Erosion → Dilation)
● Opening is a two-step morphological operation where erosion is applied
first, followed by dilation.
● The purpose of opening is to remove small unwanted objects while
keeping the major structures of the objects intact.
Effects of Opening
● Removes small objects and noise.
● Preserves the overall shape of larger objects.
● Smoothens object outlines.
● Useful when tiny unwanted white areas need to be removed.
Example
● In an image affected by salt noise, erosion removes these tiny dots, but it
may slightly shrink the main objects.
● The following dilation step restores the main object’s size while keeping
the noise removed.
(d) Closing (Dilation → Erosion)
● Closing is the opposite sequence of opening.
● It first applies dilation, which expands the white regions, and then
applies erosion, which brings the object back to its original size.
● The goal of closing is to fill small holes and gaps inside or between
objects.
Effects of Closing
● Fills small holes inside objects.
● Connects broken parts of an object.
● Smoothens boundaries by closing gaps.
● Good for removing “pepper noise” (small black dots inside white
regions).
Example
If a straight white line on a dark background has small breaks or missing pixels,
closing will fill these breaks and make the line appear continuous again.
(e) Hit-or-Miss Transformation
● Hit-or-Miss is a powerful morphological operation used for shape
detection.
● Unlike erosion and dilation, hit-or-miss needs two structuring elements:
1. One for foreground (object)
2. One for background
● The transformation matches a specific pattern exactly. If the pattern
matches perfectly, the point is marked.
Uses
● Corner detection
● Detecting end-points of lines
● Finding exact shapes in an image
● Identifying junctions or specific patterns
—---------------------------------------------------------------------------------------------
2. Image Restoration:
● Image restoration is the process of recovering the original image that
has been degraded due to noise, blur, or poor lighting.
● The aim is to improve image quality so that important details become
visible.
● Restoration techniques depend on understanding the noise model and
using proper filters.
(a) Noise Models
● Noise refers to unwanted random variations in pixel intensities.
● Noise may enter during:
○ Image capturing (sensor defects)
○ Transmission (loss of data)
○ Environmental factors (low light, atmospheric interference)
○ Hardware limitations (electronic noise)
Common Noise Types
1. Gaussian Noise
○ Appears as grainy, smooth variations across the image.
○ It is caused by electronic systems, camera sensors, and natural
variations.
○ This is the most common type of noise found in real-world
photographs.
2. Salt-and-Pepper Noise
○ Appears as random dark(pepper) and bright(salt) dots.
○ Caused by faulty camera sensors or transmission errors.
3. Speckle Noise
○ Seen especially in medical (ultrasound) and radar images.
○ Caused due to wave interference, making the image look grainy
and patchy.
Understanding noise helps in choosing the right filter.
(b) Mean Filters
● Mean filters replace each pixel with the average value of its
neighborhood.
● This reduces sudden intensity variations and smooths the image.
Types of Mean Filters
1. Arithmetic Mean Filter
○ Calculates the simple average of pixels in the neighborhood.
○ Good for mild noise but blurs edges.
2. Geometric Mean Filter
○ Multiplies all pixel values and takes the root.
○ Preserves edges and fine details better than simple averaging.
3. Harmonic Mean Filter
○ Good for removing salt noise.
○ Used in low-light images.
Advantages
● Easy to implement
● Computationally simple
● Good for reducing Gaussian noise
Disadvantage
● Blurs sharp edges and fine details
● Not suitable for images where edges are important
(c) Order Statistics Filters
● These filters use sorting instead of averaging.
● After sorting the neighboring pixels, one value is selected.
Most Important: Median Filter
● Replaces each pixel with the median of neighbors.
● Extremely effective for removing salt-and-pepper noise.
● Unlike mean filters, it does not blur edges.
Other Filters
● Max Filter: highlights bright areas, removes black noise
● Min Filter: removes white noise, darkens image
Advantages
● Max filter chooses the highest value → brightens image and removes
pepper noise.
● Min filter chooses the lowest value → removes salt noise but darkens
the image.
(d) Adaptive Filters
● Adaptive filters change their behavior based on local image statistics like
mean and variance.
Characteristics
● Adjust to variations in noise across the image
● Provide better results than fixed filters
● Useful in real-world images where noise is not uniform
Applications
● Medical imaging
● Satellite images
● Areas with mixed noise levels
(e) Wiener Filter
● Wiener filter is one of the best filters for restoring blurred or noisy
images.
Features
● Works based on Minimum Mean Square Error (MMSE) principle
● Uses local mean and variance
● Balances smoothing with detail preservation
● Reduces both blur and Gaussian noise effectively
Advantages
● Removes Gaussian noise efficiently
● Sharpens the image
● Very good for deblurring
Applications
● Astronomy
● Microscopy
● High-quality image reconstruction
—---------------------------------------------------------------------------------------------
3. Corner and Interest Point Detection:
● Corners are points where two edges meet.
● They are important because they represent unique information in an
image.
● Corners remain stable even if the image rotates or changes slightly, so
they are used for matching and tracking objects.
Harris Corner Detector
● The Harris detector is one of the most widely used methods for interest
point detection.
Concept
● A small window is moved around the image.
● If shifting the window in any direction causes a large intensity change, it
is a corner.
● If change is small, it is an edge or flat region.
Steps of Harris Algorithm
1. Find image gradients (Ix, Iy)
○ These represent changes in intensity in x and y directions.
2. Form the Structure Tensor Matrix (M)
○ This matrix contains information about gradient changes.
3. Compute Harris Response (R)
○ Using formula:
R = det(M) – k(trace(M))²
where k is a constant (0.04–0.06)
4. Interpret Values
○ R > threshold → Corner
○ R ≈ 0 → Edg
○ R < 0 → Flat region
Corner Signals and Shifts
Flat Region
● It is an area where pixel intensity remains constant.
● When the window is shifted in any direction, there is almost no change in
intensity.
● As a result, the Harris response value R is very small, indicating no
interesting features.
● Thus, flat regions are not considered corners.
Edge
● Here, intensity changes strongly in only one direction.
● Shifting the window parallel to the edge causes very little change, while
shifting perpendicular gives a big change.
● Because change is only in one direction, the Harris response R stays
small or close to zero, so it is not a true corner.
Corner
● It has strong intensity changes in both directions.
● Regardless of the direction in which the window shifts, the intensity
varies significantly.
● Therefore, the Harris response becomes large and positive, indicating
the presence of a strong corner.
Performance at Crossing Points and Junctions
● Crossing points like X-junctions, T-junctions, and L-junctions have
intensity variations in multiple directions.
● Harris gives:
○ Higher response
○ Very accurate detection
○ Stable results
Applications
● Object recognition
● Image matching
● Tracking in videos
● Feature extraction for machine learning
—---------------------------------------------------------------------------------------------