Dip M5
Dip M5
MODULE 5
S . I N
IMAGE
TUN OS
T E
EGMENTATION
K
References:
• S. Jayaraman, S. Esakkirajan, “DIGITAL IMAGE PROCESSING”
• Rafael C Gonzalez, R Woods, “DIGITAL IMAGE PROCESSING”
E S . I N
• Segmentation based on Thresholding
O T
• Edge based K TUN
Segmentation
– Classification of Edges
– Edge Detection
• Hough transform
• Active Contour
S . I N
T U N OTE
K
S . I N
OTE
Application Suitable for images with uniform properties Suitable for images with varying properties
(LBP)
K T U N
Examples Global thresholding, K-means clustering
, Fourier Transform-based segmentation
Adaptive thresholding,
region growing, Local Binary Patterns
S . I N
• Region approachT U N OTE
K
– Each pixel is assigned to a particular object or region.
• Boundary approach
– Attempt is to locate directly the boundaries that exist
between the regions
• Edge approach
– Edges are identified first, and are linked together to form
required boundaries
Downloaded from Ktunotes.in
Region Approach to Image Segmentation
• Regions in an image are a group of connected pixels
with similar properties.
• In region approach, each pixel is assigned to a
particular object or region.
• Region-based segmentation is based on the connectivity
S . I N
T U N OTE
of similar pixels in a region.
K
• Each region must be uniform.
• Connectivity of the pixels within the region is very important.
• 3 main approaches to region-based segmentation:
– Region growing
– Region splitting
– Region splitting and merging
(a ) Ri R
i 1
E S . I N
U N O
(b)R i is a connected region, Ti= 1,2,...,n
(c) R ∩ R = φ K
i forTall i and j ,i≠ j
j
(d) P (R i )= TRUE for i= 1,2,...,n
(e) P( R i∪ R j )= FALSE for any adjacent regions Ri and R j
where P(Rk): a logical predicate defined over the points in
set Rk
For example: P(Rk)=TRUE if all pixels in Rk have the same
gray level. Downloaded from Ktunotes.in
Region Growing
• Groups pixels or sub-regions into larger regions based on predefined
criteria.
• Neighbouring pixels are examined and added to a region class if no edges
are found.
• This process is iterated for each boundary pixel in the region.
• The basic idea is to start with a set of seed points and from these grow
regions by appending to each seed those neighboring pixels that have
S . I N
properties similar to the seed (specified ranges of gray level or colour)
N OTE
• Seed points are found out by computing the same set of properties for
T U
K
every pixel values.
• The resultant segment is removed from the process
• New seed is chosen from the remaining pixels.
• This continues until all pixels have been allocated to a segment
• Region-growing algorithms vary depending on the criteria used to decide
whether a pixel should be included in the region or not, the connectivity
type used to determine neighbours and the strategy to visit neighbouring
pixels
Downloaded from Ktunotes.in
Region growing is a
simple and effective
image segmentation
technique that starts
from one or more seed
points and iteratively
adds neighboring pixels
that have similar
properties to the growing
region. This method is
particularly useful for
S . I N
T U N OTE
K
• Clustering is obtained by
cutting the dendrogram at a
desired level: each connected
component forms a cluster.
• Agglomerative (bottom-up):
– Start with each document being a single cluster.
– Merge clusters to be larger and larger by starting with N
single point clusters
– Eventually all documents belong to the same cluster.
S . I N
• Divisive (top-down): N
T U OTE
K
– Start with all documents belong to the same cluster.
– Iterative splitting of the dataset until the single-point
clusters are attained on leaf nodes
– Eventually each node forms a cluster on its own.
– Does not require the number of clusters k in advance
E S . I N
OT
Starts with all pixels in a single
K T U N cluster.
Recursively splits clusters until
each pixel is its own cluster or a
stopping criterion is met.
K T U Nx c i , y c j
OTE
data structure.
Applications:
Hierarchical clustering is widely used in various fields, including:
Bioinformatics: Clustering genes or proteins based on their expression levels or sequence similarity.
Marketing: Segmenting customers based on purchasing behavior or demographic data.
Document Clustering: Grouping similar documents for information retrieval or topic modeling.
U N OTE
• Procedure start from an initial solution with a known
T
number of clusters
K
• Categorised into
– Partitioning relocation algorithms
Probabilistic clustering
K-medoids
K-means Clustering
– Density-based partitioning
Downloaded from Ktunotes.in
K-Means clustering is a popular
partitional clustering algorithm used
in image segmentation and various
• It is an iterative procedure
• Clusters data by iteratively computing a mean intensity
for each class and segmenting the image by classifying
each pixel in the class with the closest mean.
S . I N
T U N OTE
K
Initialization: randomly the data points are the centroid is
choose assigned to the K updated for each
K centroids sets set
4
k1
3
S . I N
UkN OTE
2 KT 2
k3
0
0 1 2 3 4 5
4
k1
3
S . I N
UkN OTE
2 KT 2
k3
0
0 1 2 3 4 5
4
k1
3
S . I N
T U N OTE
2 K
k3
1
k2
0
0 1 2 3 4 5
4
k1
3
S . I N
T U N OTE
2 K
k3
1
k2
0
0 1 2 3 4 5
expression in condition 2 5
4
k1
3
S . I N
T U N OTE
2 K
k2
k3
1
0
0 1 2 3 4 5
expression in condition 1
Downloaded from Ktunotes.in
Fuzzy Clustering
• Clustering methods can be classified as HARD or FUZZY
• In hard clustering, data is divided into distinct clusters,
where each data element belongs to exactly one cluster.
In fuzzy clustering (also referred to as soft clustering), data
elements can belong to more than one cluster, and
. I N
associated with each element is a set of membership levels.
S
N OTE
• These indicate the strength of the association between that
T U
K
data element and a particular cluster. Fuzzy clustering is a
process of assigning these membership levels, and then
using them to assign data elements to one or more clusters.
• Fuzzy clustering methods can be considered to be superior
to those of their hard counterparts since they can represent
the relationship between the i/p pattern data and clusters
more naturally.
Downloaded from Ktunotes.in
Fuzzy Clustering
S . I N
T U N OTE
K
S . I N
T U N OTE
K
T U N
K into sub-images.
Divide the image
the local pixel intensities.
S . I N
T U N OTE
K
Object Segmentation:
Image thresholding is
also commonly used in
computer vision tasks
such as object
segmentation, where it
helps to separate
foreground objects from
the background. This
enables more accurate
and efficient detection
of objects within an
image.
S . I N
T U N OTE
K
• If two dominant modes characterize the image histogram, it
is called a bimodal histogram. Only one threshold is enough
for partitioning the image.
• If for example an image is composed of two types of light
objects on a dark background, three or more dominant
modes characterize the image histogram.
Downloaded from Ktunotes.in
Histogram based Threshold selection
E S I N
the spatial characteristics of an.image.
• This causes it to U
be N O T
sensitive to noise and intensity
K T
inhomogeneities.
• No guarantees of object coherency— may have
holes, extraneous pixels, etc.
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
• 2 x 2 mask is given by
S . I N
T U N OTE
K
• Setting c = 1, Prewitt operator mask is given by
S . I N
T U N OTE
K
• Noise suppression characteristic is better
than prewitt mask
S . I N
T U N OTE
K
T U N OTE
• 9 frie-chen masks are given below
K
S . I N
T U N OTE
K
K T N
response to the edge. Thus non-maximum suppression can help to
U
suppress all the gradient values to 0 except the local maximal, which
indicates location with the sharpest change of intensity value. The
algorithm for each pixel in the gradient image is:
– Compare the edge strength of the current pixel with the edge
strength of the pixel in the positive and negative gradient directions.
– If the edge strength of the current pixel is the largest compared to
the other pixels in the mask with the same direction(i.e., the pixel
that is pointing in the y direction, it will be compared to the pixel
above and below it in the vertical axis), the value will be preserved.
Otherwise, the value will be suppressed.
Downloaded from Ktunotes.in
Applying double threshold (Hysteresis)
• There are still some edge pixels at this point caused by noise
and color variation. It is essential to filter out the edge pixel
with the weak gradient value and preserve the edge with the
high gradient value.
• Set two threshold values – High threshold value 𝑇1 and Low
threshold value 𝑇2
S . I N
N OTE
• If the edge pixel’s gradient value is higher than 𝑇1 , they are
T U
K
marked as strong edge pixels.
• If the edge pixel’s gradient value is smaller than 𝑇1 and larger
than 𝑇2 , they are marked as weak edge pixels.
• If the pixel value is smaller than 𝑇2 , they will be suppressed.
• The two threshold values are empirically determined values,
which will need to be defined when applying to different
images.
Downloaded from Ktunotes.in
Track edge by hysteresis
• The weak edge pixels can either be extracted from the true
edge, or the noise/color variations.
• the weak edge pixel caused from true edges will be
connected to the strong edge pixel.
• To track the edge connection, Binary Large OBject-analysis is
S . I N
T U
neighborhood pixels. OTE
applied by looking at a weak edge pixel and its 8-connected
N
K
• As long as there is one strong edge pixel is involved in the
BLOB, that weak edge point can be identified as one that
should be preserved.
S . I N
T U N OTE
K
S . I N
T U N OTE
Prewitt operators
K
Sobel operators
S . I N
T U N OTE
K
Sobel masks for
detecting diagonal edges
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
S . I N
T U N OTE
K
• Thus the energy of the snake corresponds to 3 different
forces
– Internal forces b/w points of the contour
– Image forces such as gray level and gradient magnitude that pull the
snake towards the optimal boundary position
– External constraints such as user forces applied to the contour
Downloaded from Ktunotes.in
Internal forces
• Advantages
– Computational efficiency
– Relative simplicity
• Disadvantages
. I N
– Poor convergence property of the active contour –
S
U N OTE
specifically, concavities in the object of interest are
T
K
rarely covered
– Limited Capture range, which is related to the
initialisation of the snake around the object of interest