Lecture 8 Segmentation
Lecture 8 Segmentation
Theory to Applications
Course Instructor:
Dr. M. Ehatisham-ul-Haq
Email: [email protected])
Instructor
• Research Interests:
– Signal, Image, and Video Processing
– Computer Vision and AI
– Machine Learning and Deep Learning
– Pervasive Computing and AI
Textbook:
• Rick Szeliski, Computer Vision:
Algorithms and Applications
online at http://szeliski.org/Book/
Segmentation & Clustering
Disclaimer: Many slides have been borrowed from Devi Parikh and Kristen Grauman, who may have borrowed some of them from
others. Any time a slide did not already have a credit on it, I have credited it to Kristen. So there is a chance some of these credits
are inaccurate.
5
Grouping in vision
• Goals:
– Gather features that belong together
– Obtain an intermediate representation that compactly
describes key image or video parts
6
Examples of grouping in vision
[http://poseidon.csd.auth.gr/LAB_RESEARCH/Latest/imgs/Sp
eakDepVidIndex_img2.jpg]
[Figure by J. Shi]
Group video frames into shots
Determine image regions Fg / Bg
Figure-ground
Object-level grouping
7
Grouping in vision
• Goals:
– Gather features that belong together
– Obtain an intermediate representation that compactly
describes key image (video) parts
8
The goals of segmentation
• Separate image into coherent “objects”
image human segmentation
9
Source: Lana Lazebnik
The goals of segmentation
• Separate image into coherent “objects”
“superpixels”
X. Ren and J. Malik. Learning a classification model for segmentation. ICCV 2003.
10
Source: Lana Lazebnik
Image segmentation: toy example
white
pixels
3
pixel count
black pixels
gray
1 2 pixels
input image
intensity
pixel count
input image
intensity
12
pixel count
input image
intensity
13
0 190 255
intensity
3
1 2
14
Segmentation by Thresholding
• Suppose that the gray-level histogram corresponds
to an image f(x,y) composed of dark objects on the
light background, in such a way that object and
background pixels have gray levels grouped into two
dominant modes. One obvious way to extract the
objects from the background is to select a threshold
‘T’ that separates these modes.
• Then any point (x,y) for which f(x,y) < T is called an
object point, otherwise, the point is called a
background point.
Gray Scale Image Example
22
K-means clustering
• Basic idea: randomly initialize the k cluster centers, and
iterate between the two steps we just saw.
1. Randomly initialize the cluster centers, c1, ..., cK
2. Given cluster centers, determine points in each cluster
• For each point p, find the closest ci. Put p into cluster i
3. Given points in each cluster, solve for ci
• Set ci to be the mean of points in cluster i
4. If ci have changed, repeat Step 2
Properties
• Will always converge to some solution
• Can be a “local minimum”
• does not always find the global minimum of objective function:
23
Source: Steve Seitz
K-means: pros and cons
Pros
• Simple, fast to compute
• Converges to local minimum of
within-cluster squared error
Cons/issues
• Setting k?
• Sensitive to initial centers
• Sensitive to outliers
• Detects spherical clusters
• Assuming means can be computed
24
Segmentation as clustering
Depending on what we choose as the feature space, we
can group pixels in different ways.
B
R=245
G G=220
B=248
R=15 R=3
G=189 G=12
R B=2 B=2
Feature space: color value (3-d) 26
Segmentation as clustering
Depending on what we choose as the feature space, we can
group pixels in different ways.
Intensity
• Region-based Segmentation
• Morphological Filters
Topic: Region-based Segmentation
• Region-based Segmentation
• Morphological Filters
Why Region-Based Segmentation?
• Segmentation
– Edge detection and
Thresholding not always
effective.
• Homogenous regions
– Region-based
segmentation.
– Effective in noisy images.
Definitions
• Based on sets.
• Each image R is a set of R7
R6
regions Ri.
– Every pixel belongs to R1
R5
one region.
– One pixel can only R2 R3
belong to a single region. R4
Grouping in Vision
Segmentation as Clustering
Mode finding & Mean-Shift
R7
Graph-Based Algorithms R6
Segments as Primitives
CNN-Based Approaches
R1
R5
R2
R3
R4
VC 14/15 - TP9 -
Region-Based
Segmentation
Basic Formulation
Initial Stop
Iterations
Regions Condition
Grouping in Vision
Segmentation as Clustering
Mode finding & Mean-Shift
Graph-Based Algorithms
Segments as Primitives
CNN-Based Approaches
VC 14/15 - TP9 -
Region-Based
Segmentation
Region merging
• Algorithm
– Divide image into an initial set of regions.
• One region per pixel is the smallest possible region.
– Define a similarity criteria for merging regions.
– Merge similar regions.
– Repeat previous step until no more merge
operations are possible.
Similarity Criteria
• Homogeneity of regions is used as the main
segmentation criterion in region growing.
– gray level
– color, texture
– shape
– model Choice of criteria
– etc. affects segmentation
results dramatically!
Gray-Level Criteria
• Comparing to Original Seed Pixel
– Very sensitive to choice of seed point.
• Comparing to Neighbor in Region
– Allows gradual changes in the region.
– Can cause significant drift.
• Comparing to Region Statistics
– Acts as a drift dampener.
• Other possibilities!
Region splitting
• Algorithm
R1 R2
– One initial set that
R1
includes the whole
R3 R4
image.
– Similarity criteria.
– Iteratively split regions
into sub-regions.
R1 R2
– Stop when no more R1 R2 R3
R R
splittings are possible.
R4 R5 R6 R7 R3 R
4 R
5
6 7
Grouping in Vision
Segmentation as Clustering
Mode finding & Mean-Shift
Graph-Based Algorithms
Segments as Primitives
CNN-Based Approaches
VC 14/15 - TP9 -
Region-Based
Segmentation [Machine Vision; David Vernon]
Split and Merge
• Combination of both
algorithms.
• Can handle a larger
variety of shapes.
– Simply apply previous
algorithms
consecutively.
Topic: Morphological Filters
• Region-based Segmentation
• Morphological Filters
Mathematical Morphology
Dilation Erosion
Closing Opening
Example: Opening
Opening
Tresholding
VC 14/15 - TP9 -
Region-Based
Segmentation
Example: ?
?
Example: Closing
Closing
Questions?