Class of Image Processing
CHAPTER 5
Image
Segmentation
6 Periods
Department of Mechatronics
EIU - 2017
[Link] Le
Chapter outcomes
• Understand how to detect discontinuous point,
line edge ?
• Use Hough transform to detect straight lines
• Understand basic methods of thresholding
• What is segmentation ?
[Link] Le
Contents
• This lecture will cover:
– Detection of Discontinuities
– Edge Linking and Boundary Detection
– Thresholding
– Region-Based Segmentation
– Segmentation by Morphological Watersheds
– The Use of Motion in Segmentation
[Link] Le
Image Segmentation
• Image segmentation divides an image into
regions: connected and have some similarity
within the region and some difference between
adjacent regions.
• The goal is usually to find individual objects in an
image.
• For the most part there are fundamentally two
kinds of approaches to segmentation:
discontinuity and similarity.
– Similarity may be due to pixel intensity, color or texture.
– Differences are sudden changes (discontinuities) in any
of these, but especially sudden changes in intensity
along a boundary line, which is called an edge.
[Link] Le
Detection of Discontinuities
• There are three kinds of discontinuities of
intensity: points, lines and edges.
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
• The most common way to look for discontinuities
is to scan a small mask over the image.
• The mask determines which kind of discontinuity
to look for. 9
R w1 z1 w2 z 2 ... w9 z9 wi zi
i 1
[Link] Le
Detection of Discontinuities
Point Detection
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
R T
where T : a nonnegative threshold
[Link] Le
Detection of Discontinuities
Line Detection
• Only slightly more common than point detection
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
is to find a one pixel wide line in an image.
• For digital images the only three point straight
lines are only horizontal, vertical, or diagonal (+
or –45).
[Link] Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Line Detection
Detection of Discontinuities
[Link] Le
Detection of Discontinuities
Gradient Operators
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Roberts cross-gradient operators
Prewitt operators
Sobel operators
[Link] Le
Detection of Discontinuities
Gradient Operators
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Prewitt masks for
detecting diagonal edges
Sobel masks for
detecting diagonal edges
[Link] Le
Detection of Discontinuities
Gradient Operators: Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
f Gx G y
[Link] Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Detection of Discontinuities
[Link] Le
Gradient Operators: Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Detection of Discontinuities
[Link] Le
Gradient Operators: Example
Detection of Discontinuities
Gradient Operators
• Second-order derivatives: (The Laplacian)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
– The Laplacian of an 2D function f(x,y) is
defined as
2 2 f 2 f
f 2 2
x y
– Two forms in practice:
[Link] Le
Edge Linking and Boundary
Detection Global Processing via the
Hough Transform
• Hough transform: a way of finding edge points in
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
an image that lie along a straight line.
• Example: xy-plane v.s. ab-plane (parameter
space)
yi axi b
[Link] Le
Edge Linking and Boundary
Detection Global Processing via the
Hough Transform
• The Hough transform consists
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of finding all pairs of values of
and which satisfy the
equations that pass through
(x,y).
• These are accumulated in
what is basically a 2-
dimensional histogram.
• When plotted these pairs of
and will look like a sine wave.
The process is repeated for all x cos y sin
appropriate (x,y) locations.
[Link] Le
Edge Linking and Boundary
Detection Hough Transform Example
The intersection of the
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
curves corresponding to
points 1,3,5
2,3,4
1,4
[Link] Le
Edge Linking and Boundary
Detection Hough Transform Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
[Link] Le
Thresholding
• Assumption: the range of intensity levels covered by
objects of interest is different from the background.
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
1 if f ( x, y ) T
g ( x, y )
0 if f ( x, y ) T
Single threshold Multiple threshold
[Link] Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Thresholding
The Role of Illumination
[Link] Le
Thresholding
The Role of Illumination
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
r ( x, y ) (a) (c) i ( x, y )
(d) (e)
f ( x, y ) i ( x, y )r ( x, y )
[Link] Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Thresholding
Basic Global Thresholding
[Link] Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Thresholding
Basic Global Thresholding
[Link] Le
Thresholding
Basic Global Thresholding
• Iterative method for calculating threshold:
Initialize: T = x
REPEAT
- Segment the image using T.
1 1
- Calculate segment averages: x1
n1
x T
xi and x 2
n2
x
xi T
i
i
x1 x 2
- Recalculate threshold: T
2
UNTIL T does not change.
[Link] Le
Thresholding
Basic Adaptive Thresholding
[Link] Le
Thresholding
Basic Adaptive Thresholding
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
How to solve this problem?
[Link] Le
Thresholding
Basic Adaptive Thresholding
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Answer: subdivision
[Link] Le
Thresholding
Optimal Global and Adaptive Thresholding
• This method treats pixel values as probability density
functions.
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
• The goal of this method is to minimize the probability
of misclassifying pixels as either object or
background.
• There are two kinds of error:
– Mislabeling an object pixel as background, and
– Mislabeling a background pixel as object.
OTSU & ENTROPY
Method
[Link] Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Thresholding
Use of Boundary Characteristics
[Link] Le
Region-Based Segmentation
• Edges and thresholds sometimes do not
give good results for segmentation.
• Region-based segmentation is based on the
connectivity of similar pixels in a region.
– Each region must be uniform.
– Connectivity of the pixels within the region is
very important.
• There are two main approaches to region-
based segmentation: region growing and
region splitting.
[Link] Le
Region-Based Segmentation
Basic Formulation
• Let R represent the entire image region.
• Segmentation is a process that partitions R into
subregions, R1,R2,…,Rn, such that
n
(a) Ri R
i 1
(b) Ri is a connected region, i 1,2,..., n
(c) Ri R j for all i and j , i j
(d) P ( Ri ) TRUE for i 1,2,..., n
(e) P ( Ri 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.
[Link] Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Region Growing
Region-Based Segmentation
[Link] Le
Region-Based Segmentation
Region Growing
• Fig. 10.41 shows the histogram of Fig. 10.40 (a). It
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
is difficult to segment the defects by thresholding
methods. (Applying region growing methods are
better in this case.)
Figure 10.40(a) Figure 10.41
[Link] Le
The Use of Motion in
Segmentation
• Subtraction of the car going from left to right to
establish a reference image.
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
• Repeating the task for all moving objects may result
in a static reference image.
• The method works well only in simple scenarios.
[Link] Le
[Link] Le