800 likes | 960 Views
CSE 473/573 Computer Vision and Image Processing (CVIP). Ifeoma Nwogu Lectures 21 & 22 – Segmentation and clustering. Schedule. Last class We started on segmentation Today Segmentation continued Readings for today: Forsyth and Ponce chapter 9; Szelinski chapter 5.
E N D
CSE 473/573 Computer Vision and Image Processing (CVIP) Ifeoma Nwogu Lectures 21 & 22 – Segmentation and clustering
Schedule • Last class • We started on segmentation • Today • Segmentation continued • Readings for today: • Forsyth and Ponce chapter 9; • Szelinski chapter 5
Digital image manipulations • Image processing image in → image out • Image analysis image in → measurements out • Image understanding image in → high-level description out
Motion and perceptual organization Humans interpret information “collectively” or in groups
Slides accompanying Forsyth and Ponce “Computer Vision - A Modern Approach” 2e by D.A. Forsyth
Image segmentation The main goal is to identify groups of pixels/regions that “go together perceptually”
Image segmentation Separate image into “coherent objects”
Why do segmentation? • To obtain primitives for other tasks • For perceptual organization, recognition • For graphics, image manipulation
Task 1: Primitives for other tasks • Group together similar-looking pixels for efficiency of further processing • “Bottom-up” process • Unsupervised “superpixels” X. Ren and J. Malik. Learning a classification model for segmentation. ICCV 2003.
Example of segments as primitives for recognition • Image parsing or semantic segmentation: J. Tighe and S. Lazebnik, ECCV 2010, IJCV 2013
Task 2: Recognition • Separate image into coherent “objects” • “Bottom-up” or “top-down” process? • Supervised or unsupervised? human segmentation image Berkeley segmentation database:http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/
Task 3: Image manipulation • Interactive segmentation for graphics
High-level approaches to segmentation • Bottom-up: group tokens with similar features • Top-down: group tokens that likely belong to the same object [Levin and Weiss 2006]
Approaches to segmentation • Segmentation as clustering • Segmentation as graph partitioning • Segmentation as labeling (?)
Segmentation as clustering • Clustering: grouping together similar points and represent them with a single token • Key Challenges: • What makes two points/images/patches similar? • How do we compute an overall grouping from pairwise similarities?
Segmentation as clustering Source: K. Grauman
K-means algorithm 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 • Initialize cluster centers: c0 ; t=0 • Assign each point to the closest center • Update cluster centers as the mean of the points • Repeat 2-3 until no points are re-assigned (t=t+1)
K-means: design choices • 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
How to choose the number of clusters? • Minimum Description Length (MDL) principle for model comparison • Minimize Schwarz Criterion • also called Bayes Information Criteria (BIC) sum squared error
How to choose the number of clusters? • Validation set • Try different numbers of clusters and look at performance • When building dictionaries (discussed in a previous class), more clusters typically work better
How to evaluate clusters? • 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
Common similarity/distance measures • P-norms • City Block (L1) • Euclidean (L2) • L-infinity • Mahalanobis • Scaled Euclidean • Cosine distance Here xi is the distance between two points
Conclusions: K-means Good • Finds cluster centers that minimize conditional variance (good representation of data) • Simple to implement, widespread application Bad • Prone to local minima • Need to choose K • All clusters have the same parameters (e.g., distance measure is non-adaptive) • Can be slow: each iteration is O(KNd) for N d-dimensional points
K-medoids • Just like K-means except • Represent the cluster with one of its members, rather than the mean of its members • Choose the member (data point) that minimizes cluster dissimilarity • Applicable when a mean is not meaningful • E.g., clustering values of hue or using L-infinity similarity
K-Means pros and cons • Pros • Simple and fast • Easy to implement • Cons • Need to choose K • Sensitive to outliers • Usage • Rarely used for pixel segmentation
Mean shift segmentation D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature Space Analysis, PAMI 2002. • Versatile technique for clustering-based segmentation
Mean shift algorithm • Try to find modes of this non-parametric density
Kernel density estimation (KDE) • A non-parametric way to estimate the probability density function of a random variable. • Inferences about a population are made based only on a finite data sample. • Also termed the Parzen–Rosenblatt window method, • Named fterEmanuel Parzen and Murray Rosenblatt, who are usually credited with independently creating it in its current form
Kernel density estimation Kernel density estimation function Gaussian kernel
Kernel density estimation Kernel Estimated density Data (1-D)
Mean shift Region of interest Center of mass Mean Shift vector Slide by Y. Ukrainitz & B. Sarel
Mean shift Region of interest Center of mass Mean Shift vector Slide by Y. Ukrainitz & B. Sarel
Mean shift Region of interest Center of mass Mean Shift vector Slide by Y. Ukrainitz & B. Sarel
Mean shift Region of interest Center of mass Mean Shift vector Slide by Y. Ukrainitz & B. Sarel
Mean shift Region of interest Center of mass Mean Shift vector Slide by Y. Ukrainitz & B. Sarel
Mean shift Region of interest Center of mass Mean Shift vector Slide by Y. Ukrainitz & B. Sarel
Mean shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel
Computing the Mean Shift • Simple Mean Shift procedure: • Compute mean shift vector • Translate the Kernel window by m(x) Slide by Y. Ukrainitz & B. Sarel
Attraction basin • Attraction basin: the region for which all trajectories lead to the same mode • Cluster: all data points in the attraction basin of a mode Slide by Y. Ukrainitz & B. Sarel
Mean shift filtering and segmentation for grayscale data; (a) input data (b) mean shift paths for the pixels on the plateaus (c) filtering result (d) segmentation result http://www.caip.rutgers.edu/~comanici/Papers/MsRobustApproach.pdf
Mean shift clustering • The mean shift algorithm seeks modes of the given set of points • Choose kernel and bandwidth • For each point: • Center a window on that point • Compute the mean of the data in the search window • Center the search window at the new mean location • Repeat (b,c) until convergence • Assign points that lead to nearby modes to the same cluster
Segmentation by Mean Shift • Compute features for each pixel (color, gradients, texture, etc); also store each pixel’s position • Set kernel size for features Kf and position Ks • Initialize windows at individual pixel locations • Perform mean shift for each window until convergence • Merge modes that are within width of Kf and Ks
Mean shift segmentation results http://www.caip.rutgers.edu/~comanici/MSPAMI/msPamiResults.html