Segmentation
Segmentation
(ME-4201)
Segmentation
Phung Thanh Huy
Department of Mechatronics
Ho Chi Minh City University of Technology
Vietnam National University Ho Chi Minh City
Ver2024.1
Segmentation |2
Segmentation
Segments and segmentation
Segmentation of the
image by mean-shift for radii r
= 12 (middle) and r = 24
(right),
Segmentation |3
Segmentation
Segments and segmentation
Segmentation |4
Segmentation
Segments and segmentation
Segmentation |5
Segmentation
Segments and segmentation
Segmentation |6
Segmentation by binarization
Intensity Thresholding
Global thresholding Multiple thresholding
• When the value of T changes over an image, we use the term variable
thresholding
• If T depends on the spatial coordinates (x, y) themselves, then variable
thresholding is often referred to as dynamic or adaptive thresholding
Segmentation |7
Segmentation by binarization
Intensity Thresholding
• The thresholding results are affected by noise and illumination.
Segmentation |8
Segmentation by binarization
Intensity Thresholding
• The thresholding results are affected by noise and illumination.
Segmentation |9
Segmentation by binarization
Intensity Thresholding
• Global Thresholding Algorithm
Segmentation |10
Segmentation by binarization
Otsu Binarization
Principle: maximizing the between-class variance
• Consider normalized histogram 𝑝𝑖 of an n-bit image. The intensity level: 0 → (2𝑛 − 1).
Let 𝐿 = 2𝑛
• Support 𝑇 𝑘 = 𝑘 is threshold
Segmentation |11
Segmentation by binarization
Otsu Binarization
• The cumulative mean (average intensity) up to level k
and the average intensity of the entire image (i.e., the global mean)
• Final result
Find
Segmentation |12
Segmentation by binarization
Otsu Binarization
𝑖 0 1 2 … 2𝑛 − 2 2𝑛 − 1
𝑝𝑖
𝑖𝑝𝑖
𝑃1 (𝑘)
𝑚 𝑘 𝑚𝐺
𝜎𝐵2 𝑘 𝜎𝐺2
• Obtain the Otsu threshold, 𝑘 ∗ , as the value of 𝑘 for which 𝜎𝐵2 𝑘 is maximum.
• If the maximum is not unique, obtain k* by averaging the values of k corresponding
to the various maxima detected.
Segmentation |13
Segmentation by binarization
Otsu Binarization
Segmentation |14
Segmentation by binarization
Improving the binarization
Using image smoothing
Segmentation |15
Segmentation by binarization
Improving the binarization
Using Edges
Segmentation |16
Segmentation by binarization
Improving the binarization
Using Edges
Segmentation |17
Segmentation by binarization
Multiple Thresholding
• In the case of classes, , , ..., , the between-class variance is:
• Thresholding
• Efficiency
Segmentation |18
Segmentation by binarization
Multiple Thresholding Region 3 (b)
Region 1 (a)
Region 2 (b)
Segmentation |19
Segmentation by binarization
Variable Thresholding Based on Local Image Properties
At each point (x,y), consider a neighborhood 𝑆𝑥𝑦 . Inside the neighborhood area:
Need to choose:
If the background is nearly constant + Neighborhood size.
+a
+b
Global mean
Improvement:
Segmentation |20
Segmentation by binarization
Variable Thresholding Based on Moving Averages
• Computing a moving average along scan lines of an image.
• The scanning typically is carried out line by line in a zigzag pattern to reduce
illumination bias
𝑧1
𝑚 1 =
𝑛 n: number of points for
𝑘
1 1 averaging
𝑚 𝑘 = 𝑧𝑖 = 𝑚 𝑘 − 1 + 𝑧𝑘 − 𝑧𝑘−𝑛+1
𝑛 𝑛
𝑖=𝑘−𝑛+1
n=3
Segmentation |21
Segmentation by binarization
Variable Thresholding Based on Moving Averages
• For each point
Segmentation |22
Segmentation by binarization
Variable Thresholding Based on Moving Averages
• Thresholding based on moving averages works well when the objects are small with
respect to the image size.
• Quite useful in document processing
Segmentation |23
Regional-based Segmentation
Basic Topology and Relationships of Images
Neighbors
Segmentation |24
Regional-based Segmentation
Basic Topology and Relationships of Images
Adjacency
Segmentation |25
Regional-based Segmentation
Basic Topology and Relationships of Images
Adjacency
Segmentation |26
Regional-based Segmentation
Basic Topology and Relationships of Images
Path (Curve)
Segmentation |27
Regional-based Segmentation
Basic Topology and Relationships of Images
Connectivity
Let S represent a subset of pixels in an image.
• Two pixels p and q are said to be connected in S if there exists a path between
them consisting entirely of pixels in S.
• For any pixel p in S, the set of pixels that are connected to it in S is called a
connected component of S.
• If it only has one connected component, then set S is called a connect set.
Region
Let R be a subset of pixels in an image.
• R is a region of the image if R is a connected set.
• The boundary (also called border or contour) of a region R is the set of pixels in
the region that have one or more neighbors that are not in R.
Segmentation |28
Regional-based Segmentation
Basic Topology and Relationships of Images
Distance
Segmentation |29
Regional-based Segmentation
Region Growing
• Region growing is a procedure that groups pixels or subregions into
larger regions.
• The simplest of these approaches is pixel aggregation, which starts
with a set of “seed” points and from these grows regions by
appending to each seed points those neighboring pixels that have
similar properties (such as gray level, texture, color, shape).
• Region growing based techniques are better than the edge-based
techniques in noisy images where edges are difficult to detect.
Segmentation |30