cos 429: computer vison segmentationk-means clustering • initialization: given k categories, n...
TRANSCRIPT
![Page 1: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/1.jpg)
COS 429: COMPUTER VISON
Segmentation• human vision: grouping• k-means clustering• graph-theoretic clustering• Hough transform• line fitting• RANSAC
Reading: Chapters 14, 15Some of the slides are credited to: David Lowe, David Forsyth, Christopher Rasmussen
![Page 2: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/2.jpg)
Segmentation by Clustering
• Data reduction - obtain a compact representation for interesting image data in terms of a set of components
• Find components that belong together (form clusters)
![Page 3: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/3.jpg)
Segmentation by Clustering
![Page 4: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/4.jpg)
Segmentation by Clustering
![Page 5: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/5.jpg)
Segmentation by Clustering
From: Object Recognition as Machine Translation, Duygulu, Barnard, de Freitas, Forsyth, ECCV02
![Page 6: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/6.jpg)
General ideas
• Tokens
– whatever we need to group (pixels, points, surface elements, etc., etc.)
• Bottom up segmentation
– tokens belong together because they are locally coherent
• Top down segmentation
– tokens belong together because they lie on the same object
• These two are not mutually exclusive
![Page 7: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/7.jpg)
What is Segmentation?
• Clustering image elements that “belong together”– Partitioning
• Divide into regions/sequences with coherent internal properties
– Grouping• Identify sets of coherent tokens in image
• Tokens: Whatever we need to group – Pixels – Features (corners, lines, etc.) – Larger regions with uniform colour or texture– Discrete objects (e.g., people in a crowd)– Etc.
Slide credit: Christopher Rasmussen
![Page 8: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/8.jpg)
Why do these tokens belong together?
![Page 9: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/9.jpg)
![Page 10: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/10.jpg)
![Page 11: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/11.jpg)
![Page 12: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/12.jpg)
![Page 13: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/13.jpg)
Basic ideas of grouping in human vision
• Figure-ground discrimination– grouping can be seen in
terms of allocating some elements to a figure, some to ground
– Can be based on local bottom-up cues or high level recognition
• Gestalt properties– elements in a collection of
elements can have properties that result from relationships (Muller-Lyereffect)
– A series of factors affect whether elements should be grouped together
• Gestalt factors
![Page 14: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/14.jpg)
![Page 15: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/15.jpg)
![Page 16: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/16.jpg)
![Page 17: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/17.jpg)
![Page 18: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/18.jpg)
![Page 19: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/19.jpg)
![Page 20: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/20.jpg)
![Page 21: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/21.jpg)
![Page 22: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/22.jpg)
Application: Background Subtraction
• The problem: Segment moving foreground objects from static background
• Applications– Traffic monitoring– Surveillance/security– User interaction
Current imagefrom C. Stauffer and W. Grimson
Background image Foreground pixels
courtesy of C. Wren
Pfinder
Slide credit: Christopher Rasmussen
![Page 23: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/23.jpg)
Technique: Background Subtraction
• If we know what the background looks like, it is easy to identify “interesting bits”
• Applications– Person in an office– Tracking cars on a road– surveillance
• Approach:– use a moving average to
estimate background image– subtract from current frame– large absolute values are
interesting pixels• trick: use morphological
operations to clean up pixels
![Page 24: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/24.jpg)
Algorithm
video sequence background frame difference thresholded frame diff
for t = 1:NUpdate background modelCompute frame differenceThreshold frame differenceNoise removal
end
Objects are detected where is non-zero
![Page 25: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/25.jpg)
Background Modelling
• Offline average– Pixel-wise mean values are computed during training phase (also
called Mean and Threshold)
• Adjacent Frame Difference– Each image is subtracted from previous image in sequence
• Moving average– Background model is linear weighted sum of previous frames
• Multi-Modal– Background model is Gaussian mixture model learnt from training
data
![Page 26: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/26.jpg)
Results & Problems for Simple Approaches
from K. Toyama et al.
![Page 27: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/27.jpg)
![Page 28: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/28.jpg)
![Page 29: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/29.jpg)
Background Subtraction: Issues• Noise models
– Unimodal: Pixel values vary over time even for static scenes
– Multimodal: Features in background can “oscillate”, requiring models which can represent disjoint sets of pixel values (e.g., waving trees against sky)
• Gross illumination changes– Continuous: Gradual illumination changes alter the
appearance of the background (e.g., time of day)– Discontinuous: Sudden changes in illumination and
other scene parameters alter the appearance of the background (e.g., flipping a light switch)
• Bootstrapping– Is a training phase with “no foreground” necessary, or
can the system learn what’s static vs. dynamic online?Slide credit: Christopher Rasmussen
![Page 30: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/30.jpg)
Technique: Shot Boundary Detection
• Find the shots in a sequence of video– shot boundaries usually
result in big differences between succeeding frames
• Strategy:– compute interframe
distances– declare a boundary where
these are big
• Possible distances– frame differences– histogram differences– block comparisons– edge differences
• Applications:– representation for movies,
or video sequences • find shot boundaries• obtain “most
representative” frame– supports search
![Page 31: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/31.jpg)
Segmentation as clustering
• Cluster together (pixels, tokens, etc.) that belong together• Agglomerative clustering
– attach closest to cluster it is closest to– repeat
• Divisive clustering– split cluster along best boundary– Repeat
• Dendrograms– yield a picture of output as clustering process continues
![Page 32: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/32.jpg)
Feature Space
• Every token is identified by a set of salient visual characteristics called features. For example: – Position – Color– Texture– Motion vector– Size, orientation (if token is larger than a pixel)
• The choice of features and how they are quantified implies a feature space in which each token is represented by a point
• Token similarity is thus measured by distance between points (“feature vectors”) in feature space
Slide credit: Christopher Rasmussen
![Page 33: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/33.jpg)
![Page 34: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/34.jpg)
Matlab Code
• rand('seed',12); • X = rand(100,2); • Y = pdist(X,‘euclidean'); • Z = linkage(Y,‘single'); • [H, T] = dendrogram(Z);
![Page 35: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/35.jpg)
![Page 36: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/36.jpg)
![Page 37: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/37.jpg)
![Page 38: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/38.jpg)
![Page 39: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/39.jpg)
![Page 40: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/40.jpg)
![Page 41: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/41.jpg)
![Page 42: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/42.jpg)
![Page 43: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/43.jpg)
![Page 44: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/44.jpg)
K-Means Clustering
• Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers (means) m1, …, mK. Repeat the following:
1. Assign each of the N points, xj, to clusters by nearest mi (make sure no cluster is empty)
2. Recompute mean mi of each cluster from its member points
3. If no mean has changed more than some ε, stop
• Effectively carries out gradient descent to minimize:
x j − μ i
2
j∈elements of i'th cluster∑
⎧ ⎨ ⎩
⎫ ⎬ ⎭ i∈clusters
∑Slide credit: Christopher Rasmussen
![Page 45: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/45.jpg)
Example: 3-means Clustering
from Duda et al.
Convergence in 3 steps
![Page 46: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/46.jpg)
![Page 47: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/47.jpg)
![Page 48: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/48.jpg)
![Page 49: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/49.jpg)
![Page 50: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/50.jpg)
K-means clustering using intensity alone and color alone
Image Clusters on intensity Clusters on color
![Page 51: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/51.jpg)
K-Means
![Page 52: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/52.jpg)
EM
![Page 53: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/53.jpg)
Compare K-means VS EM
• K-means
• EM
![Page 54: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/54.jpg)
Graph theoretic clustering
![Page 55: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/55.jpg)
Graph theoretic clustering
• Sometimes, clusters have unusual shapes and K-means fails.
• Alternative approach: encode similarity of tokens instead of absolute properties
• Represent similarity of tokens using a weighted graph/affinity matrix
• Cut up this graph to get subgraphs with strong interior links
![Page 56: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/56.jpg)
Graph theoretic clustering
![Page 57: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/57.jpg)
![Page 58: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/58.jpg)
Measuring Affinity
Intensity
Texture
Distance
aff x, y( )= exp − 12σ i
2⎛ ⎝
⎞ ⎠ I x( )− I y( ) 2( )⎧
⎨ ⎩
⎫ ⎬ ⎭
aff x, y( )= exp − 12σ d
2⎛ ⎝
⎞ ⎠ x − y 2( )⎧
⎨ ⎩
⎫ ⎬ ⎭
aff x, y( )= exp − 12σ t
2⎛ ⎝
⎞ ⎠ c x( )− c y( ) 2( )⎧
⎨ ⎩
⎫ ⎬ ⎭
![Page 59: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/59.jpg)
Scale affects affinity
![Page 60: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/60.jpg)
Eigenvectors and Segmentation
• Extract a single good cluster– Where elements have high affinity values with each
other
![Page 61: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/61.jpg)
Example eigenvector
points
matrix
eigenvector
![Page 62: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/62.jpg)
Eigenvectors and Segmentation
• Extract a single good cluster• Extract weights for a set of clusters
![Page 63: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/63.jpg)
![Page 64: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/64.jpg)
![Page 65: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/65.jpg)
![Page 66: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/66.jpg)
Normalized cuts
• Current criterion evaluates within cluster similarity, but not across cluster difference
• Instead, we’d like to maximize the within cluster similarity compared to the across cluster difference
• Write graph as V, one cluster as A and the other as B
• Minimize
• (or equivalently) Maximize
• i.e. construct A, B such that their within cluster similarity is high compared to their association with the rest of the graph
![Page 67: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/67.jpg)
Normalized cuts
• Write a vector y whose elements are 1 if item is in A, -b if it’s in B
• Write the matrix of the graph as W, and the matrix which has the row sums of W on its diagonal as D, 1 is the vector with all ones.
• Criterion becomes
• and we have a constraint
• This is hard to do, because y’s values are quantized
minyyT D −W( )y
yT Dy⎛ ⎝ ⎜
⎞ ⎠ ⎟
yT D1 = 0
![Page 68: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/68.jpg)
Normalized cuts
![Page 69: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/69.jpg)
Normalized cuts
• Instead, solve the generalized eigenvalue problem
• which gives
• Now look for a quantization threshold that maximises the criterion --- i.e all components of y above that threshold go to one, all below go to -b
maxy yT D − W( )y( ) subject to yT Dy = 1( )
D − W( )y = λDy
![Page 70: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/70.jpg)
More than two segments
• Two options– Recursively split each side to get a tree, continuing till
the eigenvalues are too small– Use the other eigenvectors
![Page 71: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/71.jpg)
Normalized cuts: Summary
![Page 72: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/72.jpg)
Normalized cuts: Results
![Page 73: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/73.jpg)
Normalized cuts: Results
![Page 74: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/74.jpg)
Figure from “Image and video segmentation: the normalised cut framework”, by Shi and Malik, copyright IEEE, 1998
![Page 75: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/75.jpg)
F igure from “Normalized cuts and image segmentation,” Shi and Malik, copyright IEEE, 2000
![Page 76: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/76.jpg)
Application: Supervised Segmentation I
![Page 77: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/77.jpg)
Data in Colour Space Gaussian Models
Gaussian Colour Distributions
![Page 78: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/78.jpg)
Gaussian Colour Distributions
![Page 79: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/79.jpg)
Application: Supervised Segmentation II
![Page 80: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/80.jpg)
Mixture of Gaussian Colour Distributions
Data in Colour Space Mixture of Gaussian Models
![Page 81: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/81.jpg)
Mixture of Gaussian Colour Distributions
![Page 82: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/82.jpg)
Colour is not always sufficient…
![Page 83: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/83.jpg)
Colour is not always sufficient…
Data in Colour Space Mixture of Gaussian Models
![Page 84: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/84.jpg)
Texture = Colour in context
• Independent pixel assumption fails when foreground and background share colours
• Need to look at context– ? Over what area should we look ?
![Page 85: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/85.jpg)
Markov Random Fields
• Markov Random Fields (MRFs) express spatial dependence in terms of neighbours
• BUT this does not mean that non-neighbours are independent!
![Page 86: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/86.jpg)
Example: Markov Random Fields
A. Blake, C. Rother, M. Brown, P. Perez and P. Torr. Interactive image segmentation using an adaptive Gaussian Mixture MRF model. ECCV2004
![Page 87: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/87.jpg)
Fitting a Model to DataReading: 15.1, 15.5.2
• Cluster image parts together by fitting a model to some selected parts
• Examples:– A line fits well to a set of points. This is unlikely to be
due to chance, so we represent the points as a line.– A 3D model can be rotated and translated to closely fit
a set of points or line segments. It it fits well, the object is recognized.
![Page 88: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/88.jpg)
Line Grouping Problem
Slide credit: David Jacobs
![Page 89: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/89.jpg)
This is difficult because of:
• Extraneous data: clutter or multiple models– We do not know what is part of the model?– Can we pull out models with a few parts from much
larger amounts of background clutter?• Missing data: only some parts of model are present• Noise
• Cost:– It is not feasible to check all combinations of features
by fitting a model to each possible subset
![Page 90: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/90.jpg)
The Hough Transform for Lines
• Idea: Each point votes for the lines that pass through it.• A line is the set of points (x, y) such that
• Different choices of θ, d give different lines• For any (x, y) there is a one parameter family of lines
through this point. Just let (x,y) be constants and for each value of θ the value of d will be determined.
• Each point enters votes for each line in the family• If there is a line that has lots of votes, that will be the line
passing near the points that voted for it.
sinθ( )x + cosθ( )y + d = 0
![Page 91: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/91.jpg)
tokens Votes
Horizontal axis is θ, vertical is d.
![Page 92: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/92.jpg)
tokens votes
![Page 93: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/93.jpg)
![Page 94: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/94.jpg)
Fewer votes land in a single bin when noise increases.
![Page 95: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/95.jpg)
Adding more clutter increases number of bins with false peaks.
![Page 96: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/96.jpg)
Mechanics of the Hough transform
• Construct an array representing θ, d
• For each point, render the curve (θ, d) into this array, adding one vote at each cell
• Difficulties– how big should the cells
be? (too big, and we merge quite different lines; too small, and noise causes lines to be missed)
• How many lines?– Count the peaks in the
Hough array– Treat adjacent peaks as
a single peak• Which points belong to
each line?– Search for points close
to the line– Solve again for line
and iterate
![Page 97: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/97.jpg)
More details on Hough transform
• It is best to vote for the two closest bins in each dimension, as the locations of the bin boundaries is arbitrary.– By “bin” we mean an array location in which votes are
accumulated– This means that peaks are “blurred” and noise will not
cause similar votes to fall into separate bins• Can use a hash table rather than an array to store the votes
– This means that no effort is wasted on initializing and checking empty bins
– It avoids the need to predict the maximum size of the array, which can be non-rectangular
![Page 98: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/98.jpg)
When is the Hough transform useful?• The textbook wrongly implies that it is useful mostly for
finding lines– In fact, it can be very effective for recognizing arbitrary
shapes or objects• The key to efficiency is to have each feature (token)
determine as many parameters as possible– For example, lines can be detected much more
efficiently from small edge elements (or points with local gradients) than from just points
– For object recognition, each token should predict scale, orientation, and location (4D array)
• Bottom line: The Hough transform can extract feature groupings from clutter in linear time!
![Page 99: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/99.jpg)
RANSAC (RANdom SAmple Consensus)
1. Randomly choose minimal subset of data points necessary to fit model (a sample)
2. Points within some distance threshold t of model are a consensus set. Size of consensus set is model’s support
3. Repeat for N samples; model with biggest support is most robust fit– Points within distance t of best model are inliers– Fit final model to all inliers
Two samplesand their supports
for line-fitting
from Hartley & Zisserman Slide: Christopher Rasmussen
![Page 100: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/100.jpg)
![Page 101: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/101.jpg)
RANSAC: How many samples?
How many samples are needed?Suppose w is fraction of inliers (points from line).n points needed to define hypothesis (2 for lines)k number of samples.
Probability that a single sample of n points is correct:
Probability that all samples fail is:
Choose k high enough to keep this below desired failure rate.
nwknw )1( −
![Page 102: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/102.jpg)
RANSAC: Computed k (p = 0.99)
1177272784426958
588163543320847
29397372416746
14657261712645
723417139534
35191197433
1711765322
50%40%30%25%20%10%5%nProportion of outliers Sample
size
adapted from Hartley & Zisserman
Slide credit: Christopher Rasmussen
![Page 103: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/103.jpg)
After RANSAC
• RANSAC divides data into inliers and outliers and yields estimate computed from minimal set of inliers
• Improve this initial estimate with estimation over all inliers (e.g., with standard least-squares minimization)
• But this may change inliers, so alternate fitting with re-classification as inlier/outlier
from Hartley & Zisserman
Slide credit: Christopher Rasmussen
![Page 104: COS 429: COMPUTER VISON SegmentationK-Means Clustering • Initialization: Given K categories, N points in feature space. Pick K points randomly; these are initial cluster centers](https://reader036.vdocuments.site/reader036/viewer/2022062914/5e61fdca2d2c461f32507b95/html5/thumbnails/104.jpg)
Discussion of RANSAC
• Advantages:– General method suited for a wide range of model fitting
problems– Easy to implement and easy to calculate its failure rate
• Disadvantages:– Only handles a moderate percentage of outliers without
cost blowing up– Many real problems have high rate of outliers (but
sometimes selective choice of random subsets can help)• The Hough transform can handle high percentage of outliers