14
14
50x50
Patch
50x50
Patch
Oversegmentation Undersegmentation
Multiple Segmentations
Clustering: group together similar points and represent them
with a single token
Key Challenges:
1) What makes two points/images/patches similar?
2) How do we compute an overall grouping from pairwise similarities?
• K-means
– Iteratively re-assign points to the nearest cluster center
• Agglomerative clustering
– Start with each point as its own cluster and iteratively merge the closest
clusters
• Mean-shift clustering
– Estimate modes of pdf
• Spectral clustering
– Split the nodes in a graph based on assigned links with similarity weights
Clustering for Summarization
Goal: cluster to minimize variance in data given clusters
– Preserve information
c * , δ * argmin N1 ij c i x j
N K
2
c ,δ j i
Whether xj is assigned to ci
1. Randomly
select K centers
2. Assign each
point to nearest
center
3. Compute new
center (mean)
for each cluster
Illustration: http://en.wikipedia.org/wiki/K-means_clustering
K-means algorithm
1. Randomly
select K centers
2. Assign each
point to nearest
center
Back to 2
3. Compute new
center (mean)
for each cluster
Illustration: http://en.wikipedia.org/wiki/K-means_clustering
K-means
1. Initialize cluster centers: c0 ; t=0
• Initialization
– Randomly select K points as initial cluster center
– Or greedily choose K points to minimize residual
• Distance measures
– Traditionally Euclidean, could be others
• Optimization
– Will converge to a local minimum
– May want to perform multiple restarts
K-means clustering using intensity or color
• Generative
– How well are points reconstructed from the clusters?
• Discriminative
– How well do the clusters correspond to labels?
• Purity
– Note: unsupervised clustering does not aim to be discriminative
3. Assign a codeword
(number) to each
new patch, according
to the nearest cluster
Examples of learned codewords
distance
Conclusions: Agglomerative Clustering
Good
• Simple to implement, widespread application
• Clusters have adaptive shapes
• Provides a hierarchy of clusters
Bad
• May have imbalanced clusters
• Still have to choose number of clusters or threshold
• Need to use an “ultrametric” to get a meaningful hierarchy
Mean shift segmentation
D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature Space Analysis, PAMI 2002.
Gaussian kernel
Mean shift
Region of
interest
Center of
mass
Mean Shift
vector
Center of
mass
Mean Shift
vector
Center of
mass
Mean Shift
vector
Center of
mass
Mean Shift
vector
Center of
mass
Mean Shift
vector
Center of
mass
Mean Shift
vector
Center of
mass
n x - xi 2
xi g
i 1 h
m ( x) x
n x - xi
2
g h
i 1
g(x) k ( x)
Slide by Y. Ukrainitz & B. Sarel
Attraction basin
f( ) = “apple”
f( ) = “tomato”
f( ) = “cow”
Slide credit: L. Lazebnik
The machine learning framework
y = f(x)
output prediction Image
function feature
x
x
x x x
x
o x
x
o o
o
o
x2
x1
Steps
Training Training
Labels
Training
Images
Image Learned
Training
Features model
Testing
Image Learned
Prediction
Features model
Test Image Slide credit: D. Hoiem and L. Lazebnik
Features
• Raw pixels
• Histograms
• GIST descriptors
Test Training
Training examples
examples example
from class 2
from class 1
f(x) = sgn(w x + b)
Contains a motorbike
Underfitting Overfitting
Error
Test error
Training error
Error
Testing
Generalization Error
Training
Number of Training Examples