12 Segmentation Part2 4pp
12 Segmentation Part2 4pp
BBM 413
Fundamentals of • Goal: identify groups of pixels that go together
Image Processing
Erkut Erdem
Dept. of Computer Engineering
Hacettepe University
Segmentation – Part 2
– Partitioning
• Divide into regions/sequences with coherent internal properties
– Grouping
• Identify sets of coherent tokens in image
image human segmentation
http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/
Slide credit: S. Lazebnik Slide credit: Fei-Fei Li
Review- K-means clustering Review - K-means: pros and cons
• Basic idea: randomly initialize the k cluster centers, and Pros
iterate between the two steps we just saw.
• Simple, fast to compute
1. Randomly initialize the cluster centers, c1, ..., cK • Converges to local minimum of
2. Given cluster centers, determine points in each cluster within-cluster squared error
• 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 Cons/issues
4. If ci have changed, repeat Step 2
• Setting k?
Properties
• Sensitive to initial centers
• Will always converge to some solution
• Can be a “local minimum” • Sensitive to outliers
• does not always find the global minimum of objective function: • Detects spherical clusters
• Assuming means can be computed
http://www.caip.rutgers.edu/~comanici/MSPAMI/msPamiResults.html
D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature Space Analysis,
PAMI 2002.
Slide credit: S. Lazebnik
Mean shift algorithm
Finding Modes in a Histogram
• The mean shift algorithm seeks modes or local maxima of
density in the feature space
Feature space
image (L*u*v* color values)
Two issues:
(1) Kernel to interpolate density
based on sample positions.
(2) Gradient ascent to mode.
Mean Shift
vector
Slide credit: B. Freeman and A. Torralba Slide credit: Y. Ukrainitz & B. Sarel
Mean shift Mean shift
Search Search
window window
Center of Center of
mass mass
Slide credit: Y. Ukrainitz & B. Sarel Slide credit: Y. Ukrainitz & B. Sarel
Center of Center of
mass mass
Slide credit: Y. Ukrainitz & B. Sarel Slide credit: Y. Ukrainitz & B. Sarel
Mean shift Mean shift
Search Search
window window
Center of Center of
mass mass
Mean Shift
vector
Slide credit: Y. Ukrainitz & B. Sarel Slide credit: Y. Ukrainitz & B. Sarel
http://www.caip.rutgers.edu/~comanici/MSPAMI/msPamiResults.html
Slide credit: S. Lazebnik Slide credit: S. Lazebnik
More results Mean shift pros and cons
• Pros
– Does not assume spherical clusters
– Just a single parameter (window size)
– Finds variable number of modes
– Robust to outliers
• Cons
– Output depends on window size
– Computationally expensive
– Does not scale well with dimension of feature space
a b c d e Affinity Matrix
a é0 1 0 0 1ù a é 1 .1 .3 0 0 ù
a ê1
b b
ê 0 0 0 0úú b ê.1 1 .4 0 .2ú
ê ú
c ê0 0 0 0 1ú ê.3 .4 1 .6 .7ú
c ê ú W=
ê ú
e d
ê0 0 0 0 1ú c ê 0 0 .6 1 1 ú
e
e êë1 0 1 1 0úû 6 êë 0 .2 .7 1 1 úû
d
d Wij : probability that i &j
Adjacency Matrix
belong to the same
region
Slide credit: B. Freeman and A. Torralba * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003 Slide credit: B. Freeman and A. Torralba * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
A B C
points
Wij = exp(-|| zi – zj ||2 / s2)
With an appropriate s
eigenvector
W=
points A B
Slide credit: B. Freeman and A. Torralba * Slide from Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Normalized cuts Normalized cut
Write graph as V, one cluster as A and the other as B • Let W be the adjacency matrix of the graph
• Let D be the diagonal matrix with diagonal entries
cut(A,B) cut(A,B) D(i, i) = Σj W(i, j)
Ncut(A,B) = +
assoc(A,V) assoc(B,V) • Then the normalized cut cost can be written as
yT ( D - W ) y
cut(A,B) is sum of weights with one end in A and one end in B yT Dy
cut(A,B) = ∑ W(u,v), where y is an indicator vector whose value should be 1 in
u∈A,v ∈B the ith position if the ith feature point belongs to A and a
with A ∩ B = ∅ negative constant otherwise
assoc(A,V) is sum of all edges with one end in A.
assoc(A,B) = ∑ W(u,v)
€ u∈A,v ∈B
J. Shi and J. Malik. Normalized cuts and image segmentation. PAMI 2000 Slide credit: S. Lazebnik Slide credit: B. Freeman and A. Torralba
Boundaries of image regions defined
Global optimization
by a number of attributes
• In this formulation, the segmentation becomes a global process. – Brightness/color
• Decisions about what is a boundary are not local (as in Canny – Texture
edge detector) – Motion
– Stereoscopic depth
– Familiar configuration
Example
Affinity:
brightness Location
N pixels = ncols * nrows
W=
Slide credit: B. Freeman and A. Torralba Slide credit: B. Freeman and A. Torralba
Brightness Image Segmentation Brightness Image Segmentation
http://www.cs.berkeley.edu/~malik/papers/SM-ncut.pdf Slide credit: B. Freeman and A. Torralba http://www.cs.berkeley.edu/~malik/papers/SM-ncut.pdf Slide credit: B. Freeman and A. Torralba
http://www.cs.berkeley.edu/~malik/papers/SM-ncut.pdf Slide credit: B. Freeman and A. Torralba http://www.cs.berkeley.edu/~malik/papers/SM-ncut.pdf Slide credit: B. Freeman and A. Torralba
Example results Results: Berkeley Segmentation Engine
http://www.cs.berkeley.edu/~fowlkes/BSE/
Slide credit: S. Lazebnik Slide credit: S. Lazebnik
• Interactive segmentation
mouse
seed
Mortensen and Barrett, Intelligent
Scissors for Image Composition,
Proc. 22nd annual conference on Questions
Computer graphics and interactive
techniques, 1995
• How to define costs?
• How to find the path?
Slide credit: S. Seitz Slide credit: S. Seitz
Graph
• node for every pixel p
• link between every adjacent pair of pixels, p,q
• cost c for each link
Note: each link has a cost
• this is a little different than the figure before where each
Slide credit: S. Seitz
pixel had a cost Slide credit: S. Seitz
Defining the costs Defining the costs
• Treat the image as a graph
q q
c c
p p
Want to hug image edges: how to define cost of a link? • c can be computed using a cross-correlation filter
• the link should follow the intensity edge – assume it is centered at p
– want intensity to change rapidly to the link
• c - |difference of intensity to link| • Also typically scale c by its length
– set c = (max-|filter response|)
• where max = maximum |filter response| over all pixels in the image
Slide credit: S. Seitz Slide credit: S. Seitz
link cost
q 4 9 5
1 1 c 1
1 0 3
3 2 3
w -1
-1 -1 p
Algorithm
1. init node costs to , set p = seed point, cost(p) = 0
2. expand p as follows:
• c can be computed using a cross-correlation filter
for each of p s neighbors q that are not expanded
– assume it is centered at p
» set cost(q) = min( cost(p) + cpq, cost(q) )
4 9 5 3 2 5 4 9 5
1 1 0 3 3 2 1 1 0 3 3
3 2 3 3 4 3 3 2 3
3 2 3 3 2 3
Algorithm Algorithm
1. init node costs to , set p = seed point, cost(p) = 0 1. init node costs to , set p = seed point, cost(p) = 0
2. expand p as follows: 2. expand p as follows:
for each of p s neighbors q that are not expanded for each of p s neighbors q that are not expanded
» set cost(q) = min( cost(p) + cpq, cost(q) ) » set cost(q) = min( cost(p) + cpq, cost(q) )
» if q s cost changed, make q point back to p » if q s cost changed, make q point back to p
» put q on the ACTIVE list (if not already there) » put q on the ACTIVE list (if not already there)
3. set r = node with minimum cost on the ACTIVE list
4. repeat Step 2 for p = r
Slide credit: S. Seitz Slide credit: S. Seitz
3 2 5 4 9 5
3 2 1 1 0 3 3
3 4 3 3 2 3 s
t
4 3 2 3
Algorithm
1. init node costs to , set p = seed point, cost(p) = 0 • Graph
– node for each pixel, link between pixels
2. expand p as follows:
– specify a few pixels as foreground and background
for each of p s neighbors q that are not expanded
• create an infinite cost link from each bg pixel to the t node
» set cost(q) = min( cost(p) + cpq, cost(q) ) • create an infinite cost link from each fg pixel to the s node
» if q s cost changed, make q point back to p
– compute min cut that separates s from t
» put q on the ACTIVE list (if not already there)
– how to define link cost between neighboring pixels?
3. set r = node with minimum cost on the ACTIVE list
4. repeat Step 2 for p = r Y. Boykov and M-P Jolly, Interactive Graph Cuts for Optimal Boundary &
Slide credit: S. Seitz Region Segmentation of Objects in N-D images, ICCV, 2001. Slide credit: S. Seitz
Do we need recognition to take the next step in performance?
Random Walker
• Compute probability that a random walker arrives at seed
Normalized
cuts
Top-down
segmentation
• E. Borenstein and S. Ullman, Class-specific, top-down segmentation, • E. Borenstein and S. Ullman, Class-specific, top-down segmentation,
ECCV 2002 ECCV 2002
• A. Levin and Y. Weiss, Learning to Combine Bottom-Up and Top- • A. Levin and Y. Weiss, Learning to Combine Bottom-Up and Top-
Down Segmentation, ECCV 2006. Down Segmentation, ECCV 2006.
Slide credit: S. Lazebnik Slide credit: S. Lazebnik
Motion segmentation