(IP'22) Lecture 5 - Segmentation I - Edge-Based - Thresholding
(IP'22) Lecture 5 - Segmentation I - Edge-Based - Thresholding
Digital Image
Processing
11/7/2022 1
[email protected]
Image
Segmentation I
Fundamental Steps of DIP
Wavelet and
Multi- Compression
resolution
Output is generally images
Knowledge base
Restoration Segmentation
Representation
Enhancement and
Description
Object
Acquisition Recognition
Problem Domain
Contents
11/7/2022 12
Edge-based Approaches
- Discontinuities
Point, line, edge
- Discontinuity Detectors f
st
x
1 derivative (Gradient). f =
nd f
2 derivative (Laplacian).
y
2
f 2
f
f = 2 + 2
2
x y
Recall - Sharpening Filters
1st Derivative Example in 1D:
A B
Recall - Sharpening Filters
1st Derivative Example in 1D:
Image Strip
8
7
6
5
4
3
2
1
0
1st Derivative
8
6
4
2
0
-2
-4
-6
-8
Recall - Sharpening Filters
2nd Derivative:
The formula for the 2nd derivative of a function
is as follows:
f
2
= f ( x + 1) + f ( x − 1) − 2 f ( x )
x
2
7
6
5
4
3
2
1
0
2nd Derivative
10
-5
-10
-15
8
7
6
5
Profile 4
3
2
1
0
1st Derivative
8
6
4
2
0
1st -2
-4
-6
-8
2nd Derivative
10
-5
2nd -10
-15
Edge-based Approaches – (cont.)
- Isolated Points
Which detector?
Edge-based Approaches – (cont.)
- Isolated Points
Laplacian + threshold
Edge-based Approaches – (cont.)
- Lines
Which detector?
Edge-based Approaches – (cont.)
- Lines
Laplacian + deal with double-line effect.
Edge-based Approaches – (cont.)
- Lines
Gradient for each direction?
Edge-based Approaches – (cont.)
- Lines
Gradient for each direction?
NO!
Edge-based Approaches – (cont.)
- Lines
Masks for specific direction + threshold the
absolute value
Edge-based Approaches – (cont.)
- Lines
Edge-based Approaches – (cont.)
- Edge Models
Edge-based Approaches – (cont.)
- Ramp Edge Model
11/7/2022 39
Edge-based Approaches – (cont.)
- Hough Transform
• Based on whether a set of candidate pixels
lie on curves of a specified shape.
• Once detected, these curves form edges or
boundaries of regions.
Edge-based Approaches – (cont.)
- Hough Transform - Line
• A line in the 𝒙𝒚-plane can be expressed by
the slope-intercept form
𝒚 = 𝒂𝒙 + 𝒃
• Where
𝒂 = slope
𝒃 = 𝒚-intercept
Edge-based Approaches – (cont.)
- Hough Transform - Line
• On the other hand, the line can be
represented in the parameter space as:
𝒃 = −𝒂𝒙 + 𝒚
Edge-based Approaches – (cont.)
- Hough Transform - Line
• Hence, principal lines in 𝒙𝒚-plane can be
found by identifying points in 𝒂𝒃-plane
where large number of lines intersect.
Edge-based Approaches – (cont.)
- Hough Transform - Line
Edge-based Approaches – (cont.)
- Hough Transform - Line
• For each edge point (𝒙𝒌 , 𝒚𝒌 ), loop every
possible 𝒂𝒊 , solve for 𝒃𝒋 , and accumulate
𝒃 = −𝒂𝒙 + 𝒚
𝑨(𝒊, 𝒋).
𝑨(𝒊, 𝒋)
Edge-based Approaches – (cont.)
- Hough Transform - Line
• Pixels, which lie on the line, need not all be
contiguous (HT works even with occlusions).
Edge-based Approaches – (cont.)
- Hough Transform - Line
• Problem!
Vertical lines
have slope ~ ∞
and
𝒃 = −𝒂𝒙 + 𝒚
fails
Edge-based Approaches – (cont.)
- Hough Transform - Line
• Use the normal representation of a line
(polar coordinates)
𝒄𝒐𝒔 𝜽 𝝆
𝐲= − 𝒙+
𝒔𝒊𝒏 𝜽 𝒔𝒊𝒏 𝜽
Edge-based Approaches – (cont.)
- Hough Transform - Line
• A line can be represented in the parameter
space as: 𝛒 = 𝒙 𝒄𝒐𝒔 𝜽 + 𝒚 𝒔𝒊𝒏 𝜽
Edge-based Approaches – (cont.)
- Hough Transform - Line
• Subdivide 𝝆𝜽-space into accumulative cells
such that 𝜽𝒎𝒊𝒏 , 𝜽𝒎𝒂𝒙 : −𝟗𝟎 ≤ 𝜽 ≤ 𝟗𝟎
−𝑫 ≤ 𝝆 ≤ 𝑫 D=minimum distance between
opposite corners of image
𝑨(𝒊, 𝒋)
Edge-based Approaches – (cont.)
- Hough Transform - Line
• Number of subdivisions (steps of 𝜽 and 𝝆)
determines accuracy of colinearity of points.
𝑨(𝒊, 𝒋)
Edge-based Approaches – (cont.)
- Hough Transform - Line
• For each edge point (𝒙𝒌 , 𝒚𝒌 ), loop every
possible 𝜽𝒊 , solve for 𝝆𝒋 , and accumulate
𝑨(𝒊, 𝒋).
𝑨(𝒊, 𝒋)
Edge-based Approaches – (cont.)
- Hough Transform - Line
• Finally, examine continuity of pixels in high
count accumulator cells; usually by the
distance between disconnected pixels.
• Gaps are bridged if length of gap is less than
a certain value.
Edge-based Approaches – (cont.)
- Hough Transform - Line
Example
Edge-based Approaches – (cont.)
- Hough Transform - Line
Extract the two
edges of the
principal runway.
Edge-based Approaches – (cont.)
- Hough Transform - Line
Edge-based Approaches – (cont.)
- Hough Transform vs Probabilistic HT
Edge-based Approaches – (cont.)
- Hough Transform - Circular
Other Segmentations Methods
Active Contours
Snakes, Scissors, Level Sets
Split and Merge
Watershed, region split/merge, graph
Mean Shift
Graph Cuts
Examples
(a) active contours
(b) level sets
(c) graph-based merging
(d) mean shift (e) texture and intervening
contour-based normalized cuts
(f) binary MRF solved using graph cuts
(a) the “snake pit” for interactively controlling shape; (b) lip tracking.
Richard Szeliski, Computer Vision Algorithms and Applications, Springer 2010. Ch. 5
Examples – (cont.)
Active Contour - Scissors
(a) as the mouse traces the white path, the scissors follow the orange path along
the object boundary (the green curves show intermediate positions).
(b) regular scissors can sometimes jump to a stronger (incorrect) boundary.
(c) after training to the previous segment, similar edge profiles are preferred.
Richard Szeliski, Computer Vision Algorithms and Applications, Springer 2010. Ch. 5
Examples – (cont.)
Active Contours - Level Sets
The initial circles evolve towards an accurate segmentation of foreground and background,
adapting their topology as they evolve. (Grayscale).
Richard Szeliski, Computer Vision Algorithms and Applications, Springer 2010. Ch. 5
Examples – (cont.)
Active Contours - Level Sets
The initial circles evolve towards an accurate segmentation of foreground and background,
adapting their topology as they evolve. (Color).
Richard Szeliski, Computer Vision Algorithms and Applications, Springer 2010. Ch. 5
Thresholding
11/7/2022 65
Thresholding
• Thresholding is usually a first or intermediate
step in any segmentation approach.
a lot of
computations
Thresholding – (cont.)
Optimum Global Thresholding (Otsu)
Easier to minimize the between-class variance
Gaussian noise
with zero mean
and different
standard
deviations
Thresholding – (cont.)
Global Thresholding Problems
• Noise
• Solutions:
- Smoothing
Thresholding – (cont.)
Global Thresholding Problems
• Non-uniform illumination or reflectance
Thresholding – (cont.)
Global Thresholding Problems
• Non-uniform illumination or reflectance
Non-uniform
illumination
can result from
multiplying by
ramp pattern.
Thresholding – (cont.)
Global Thresholding Problems
• Non-uniform illumination or reflectance
Thresholding – (cont.)
Global Thresholding Problems
• Non-uniform illumination or reflectance
• Solutions:
- Correct the non-uniform shading pattern by
its inverse (requires device).
- Correcting non-uniform pattern: background
subtraction, top-hat filtering, etc.
- Or: Variable thresholding.
Thresholding – (cont.)
Variable Thresholding
• Image Partitioning
– Subdivide image into non-overlapping
rectangles.
– Small enough so that illumination of each is
approximately uniform.
– Estimate a different threshold to segment each
subimage.
Thresholding – (cont.)
Variable Thresholding
• Image Partitioning
Iterative
global
Otsu’s
method
Otsu’s on each
method partition
Thresholding – (cont.)
Variable Thresholding
• Image Partitioning
- Further subdivisions
may be required for
better results.
Thresholding – (cont.)
Variable Thresholding
• Image Partitioning
𝟏 𝒊𝒇 𝒇 𝒙, 𝒚 > 𝑻𝒙𝒚
– 𝒈 𝒙, 𝒚 = ൝
𝟎 𝒊𝒇 𝒇 𝒙, 𝒚 ≤ 𝑻𝒙𝒚
Thresholding – (cont.)
Variable Thresholding
• Local Image Properties
Thresholding – (cont.)
Variable Thresholding
• Moving Average
– Scanning is carried out line by line in zigzag pattern to reduce
illumination bias.
1 𝑘+1
– 𝑚(𝑘 + 1) = σ𝑖=𝑘+2−𝑛 𝑧𝑖
𝑛
– 𝑇𝑥𝑦 = 𝑏𝑚𝑥𝑦
1 𝑖𝑓 𝑓 𝑥, 𝑦 > 𝑇𝑥𝑦
– 𝑔 𝑥, 𝑦 = ൝
0 𝑖𝑓 𝑓 𝑥, 𝑦 ≤ 𝑇𝑥𝑦
– Works well when the objects of interest are small (or thin) with
respect to the image size, a condition satisfied in images of
handwritten text.
Thresholding – (cont.)
Variable Thresholding
• Moving Average
Next Lecture
Region-based Segmentation + Morphology
Assignment
Check book sections and associated problems
Chapter 10 1, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.7(Hough only)
11/7/2022 96
References
- Gonzalez and Woods, Digital Image Processing.
- Richard Szeliski, Computer Vision Algorithms and
Applications, Springer 2010. (Chapter 5)
http://szeliski.org/Book/
- Peters, Richard Alan, II, “Image Segmentation
(PointLineEdge)", Lectures on Image Processing, Vanderbilt
University, Nashville, TN, April 2008, Available on the web at
the Internet Archive,
http://www.archive.org/details/Lectures_on_Image_Processing.
-http://opencv-python-
tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_houghlines/py_houg
hlines.html
11/7/2022 97