Lecture: k-means & mean-shift clustering

Similar documents
Lecture: k-means & mean-shift clustering

Lecture 13: k-means and mean-shift clustering

Computer Vision Lecture 6

Computer Vision Lecture 6

CS 2750: Machine Learning. Clustering. Prof. Adriana Kovashka University of Pittsburgh January 17, 2017

Segmentation and Grouping April 19 th, 2018

CMPSCI 670: Computer Vision! Grouping

Segmentation and Grouping

Segmentation & Grouping Kristen Grauman UT Austin. Announcements

Outline. Segmentation & Grouping. Examples of grouping in vision. Grouping in vision. Grouping in vision 2/9/2011. CS 376 Lecture 7 Segmentation 1

CS 4495 Computer Vision. Segmentation. Aaron Bobick (slides by Tucker Hermans) School of Interactive Computing. Segmentation

Grouping and Segmentation

Segmentation and Grouping April 21 st, 2015

Lecture 10: Semantic Segmentation and Clustering

The goals of segmentation

CSE 473/573 Computer Vision and Image Processing (CVIP) Ifeoma Nwogu. Lectures 21 & 22 Segmentation and clustering

Segmentation Computer Vision Spring 2018, Lecture 27

Applications. Foreground / background segmentation Finding skin-colored regions. Finding the moving objects. Intelligent scissors

CS 2770: Computer Vision. Edges and Segments. Prof. Adriana Kovashka University of Pittsburgh February 21, 2017

Segmentation & Clustering

Digital Image Processing

Segmentation and Grouping

Segmentation (continued)

Grouping and Segmentation

2%34 #5 +,,% ! # %& ()% #% +,,%. & /%0%)( 1 ! # %& % %()# +(& ,.+/ +&0%//#/ &

Segmentation. Bottom Up Segmentation

CEE598 - Visual Sensing for Civil Infrastructure Eng. & Mgmt.

Clustering. Discover groups such that samples within a group are more similar to each other than samples across groups.

Lecture 7: Segmentation. Thursday, Sept 20

Image Segmentation. Marc Pollefeys. ETH Zurich. Slide credits: V. Ferrari, K. Grauman, B. Leibe, S. Lazebnik, S. Seitz,Y Boykov, W. Freeman, P.

Image Segmentation. Luc Van Gool, ETH Zurich. Vittorio Ferrari, Un. of Edinburgh. With important contributions by

Lecture 16 Segmentation and Scene understanding

Clustering. Subhransu Maji. CMPSCI 689: Machine Learning. 2 April April 2015

Image Segmentation. Selim Aksoy. Bilkent University

Image Segmentation. Selim Aksoy. Bilkent University

Clustering. So far in the course. Clustering. Clustering. Subhransu Maji. CMPSCI 689: Machine Learning. dist(x, y) = x y 2 2

Dr. Ulas Bagci

Image Analysis. Segmentation by Clustering

Image Segmentation. Shengnan Wang

Colorado School of Mines. Computer Vision. Professor William Hoff Dept of Electrical Engineering &Computer Science.

Image Segmentation. April 24, Stanford University. Philipp Krähenbühl (Stanford University) Segmentation April 24, / 63

CSSE463: Image Recognition Day 21

Computer Vision II Lecture 4

Lecture 8: Fitting. Tuesday, Sept 25

Clustering Color/Intensity. Group together pixels of similar color/intensity.

Nonparametric Clustering of High Dimensional Data

Local Features and Bag of Words Models

Announcements. Image Segmentation. From images to objects. Extracting objects. Status reports next Thursday ~5min presentations in class

Lecture: RANSAC and feature detectors

Idea. Found boundaries between regions (edges) Didn t return the actual region

In this lecture, we are going to talk about image segmentation, essentially defined as methods for grouping pixels together.

Programming assignment 3 Mean-shift

Solution: filter the image, then subsample F 1 F 2. subsample blur subsample. blur

Image gradients and edges April 11 th, 2017

Image gradients and edges April 10 th, 2018

Announcements. Segmentation & Grouping. Review questions. Outline. Grouping in vision. Examples of grouping in vision 9/21/2015

Computer Vision II Lecture 4

Applications of Image Filters

Feature Matching and Robust Fitting

What to come. There will be a few more topics we will cover on supervised learning

Image Segmentation. Computer Vision Jia-Bin Huang, Virginia Tech. Many slides from D. Hoiem

2D image segmentation based on spatial coherence

Fitting: Voting and the Hough Transform April 23 rd, Yong Jae Lee UC Davis

Texture Representation + Image Pyramids

Object Recognition. Computer Vision. Slides from Lana Lazebnik, Fei-Fei Li, Rob Fergus, Antonio Torralba, and Jean Ponce

Image gradients and edges

An Introduction to PDF Estimation and Clustering

Region-based Segmentation

Case-Based Reasoning. CS 188: Artificial Intelligence Fall Nearest-Neighbor Classification. Parametric / Non-parametric.

CS 188: Artificial Intelligence Fall 2008

Image Analysis - Lecture 5

Texture. Texture. 2) Synthesis. Objectives: 1) Discrimination/Analysis

Human Body Recognition and Tracking: How the Kinect Works. Kinect RGB-D Camera. What the Kinect Does. How Kinect Works: Overview

CS 558: Computer Vision 4 th Set of Notes

K-Means. Algorithmic Methods of Data Mining M. Sc. Data Science Sapienza University of Rome. Carlos Castillo

Image Processing and Image Analysis VU

Texture. COS 429 Princeton University

Segmentation by Clustering Reading: Chapter 14 (skip 14.5)

CS 534: Computer Vision Segmentation and Perceptual Grouping

Segmentation by Clustering. Segmentation by Clustering Reading: Chapter 14 (skip 14.5) General ideas

Clustering. Shishir K. Shah

Bias-Variance Trade-off (cont d) + Image Representations

Supervised learning. y = f(x) function

Unsupervised learning in Vision

Lecture 9: Hough Transform and Thresholding base Segmentation

Introduction to Machine Learning CMU-10701

Fitting. Lecture 8. Cristian Sminchisescu. Slide credits: K. Grauman, S. Seitz, S. Lazebnik, D. Forsyth, J. Ponce

Pattern recognition. Classification/Clustering GW Chapter 12 (some concepts) Textures

Image warping and stitching

CPSC 425: Computer Vision

Computer Vision Lecture 20

Unit 3 : Image Segmentation

Window based detectors

Classification. Vladimir Curic. Centre for Image Analysis Swedish University of Agricultural Sciences Uppsala University

PPKE-ITK. Lecture

Classification. Vladimir Curic. Centre for Image Analysis Swedish University of Agricultural Sciences Uppsala University

Computer Vision Lecture 20

Computer Vision 5 Segmentation by Clustering

Texture and Other Uses of Filters

Mixture Models and EM

Transcription:

Lecture: k-means & mean-shift clustering Juan Carlos Niebles and Ranjay Krishna Stanford Vision and Learning Lab Lecture 11-1

Recap: Image Segmentation Goal: identify groups of pixels that go together Lecture 11-2

Recap: Gestalt Theory Gestalt: whole or group Whole is greater than sum of its parts Relationships among parts can yield new properties/features Psychologists identified series of factors that predispose set of elements to be grouped (by human visual system) I stand at the window and see a house, trees, sky. Theoretically I might say there were 327 brightnesses and nuances of colour. Do I have "327"? No. I have sky, house, and trees. Max Wertheimer (1880-1943) Untersuchungen zur Lehre von der Gestalt, Psychologische Forschung, Vol. 4, pp. 301-350, 1923 http://psy.ed.asu.edu/~classics/wertheimer/forms/forms.htm Lecture 11-3

Recap: Gestalt Factors These factors make intuitive sense, but are very difficult to translate into algorithms. Lecture 11-4

What will we learn today? K-means clustering Mean-shift clustering Reading: [FP] Chapters: 14.2, 14.4 D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature Space Analysis, PAMI 2002. Lecture 11-5

What will we learn today? K-means clustering Mean-shift clustering Reading: [FP] Chapters: 14.2, 14.4 D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature Space Analysis, PAMI 2002. Lecture 11-6

Image Segmentation: Toy Example 1 2 3 black pixels gray pixels white pixels input image intensity These intensities define the three groups. We could label every pixel in the image according to which of these primary intensities it is. i.e., segment the image based on the intensity feature. What if the image isn t quite so simple? Slide credit: Kristen Grauman Lecture 11-7

Pixel count Input image Intensity Pixel count Input image Slide credit: Kristen Grauman Intensity Lecture 11-8

Pixel count Input image Intensity Now how to determine the three main intensities that define our groups? We need to cluster. Slide credit: Kristen Grauman Lecture 11-9

0 190 255 Intensity 1 2 3 Goal: choose three centers as the representative intensities, and label every pixel according to which of these centers it is nearest to. Best cluster centers are those that minimize Sum of Square Distance (SSD) between all points and their nearest cluster center c i : SSD = ( x c i ) 2 clusteri x clusteri Slide credit: Kristen Grauman Lecture 11-10

Clustering for Summarization Goal: cluster to minimize variance in data given clusters Preserve information Cluster center Data c *, δ * = argmin c, δ 1 N N j K i δ ij ( c i x ) 2 j Whether x j is assigned to c i Lecture 11-11 Slide: Derek Hoiem

Clustering With this objective, it is a chicken and egg problem: If we knew the cluster centers, we could allocate points to groups by assigning each to its closest center. If we knew the group memberships, we could get the centers by computing the mean per group. Slide credit: Kristen Grauman Lecture 11-12

K-means clustering 1. Initialize ( t = 0): cluster centers c 1,..., c K δ t denotes the set of assignment for each to cluster at iteration t 2. Compute : assign each point to the closest center δ t c t δ t = argmin δ 1. Computer : update cluster centers as the mean of the points c t = argmin c 1. Update t = t +1, Repeat Step 2-3 till stopped 1 N N K 1 N j N i K j i δ t 1 ij δ t ij x j ( c t 1 i x j ) 2 ( c t 1 x i j ) 2 c i Lecture 11-13 Slide: Derek Hoiem

K-means clustering 1. Initialize ( t = 0): cluster centers c 1,..., c K Commonly used: random initialization Or greedily choose K to minimize residual δ t 2. Compute : assign each point to the closest center Typical distance measure: Euclidean sim(x, x!) = x T x! Cosine sim(x, x!) = x T x! x x! Others c t 1. Computer : update cluster centers as the mean of the points c t = argmin c 2. Update t = t +1, Repeat Step 2-3 till stopped 1 N c t doesn t change anymore. N ( ) K j i δ t ij ( c t 1 x i j ) 2 Lecture 11-14 Slide: Derek Hoiem

K-means clustering 1. Initialize Cluster Centers 2. Assign Points to Clusters 3. Re-compute Means Repeat (2) and (3) Java demo: http://home.dei.polimi.it/matteucc/clustering/tutorial_html/appletkm.html Lecture 11-15 Illustration Source: wikipedia

K-means clustering Converges to a local minimum solution Initialize multiple runs Better fit for spherical data Need to pick K (# of clusters) Lecture 11-16

Segmentation as Clustering 2 clusters Original image 3 clusters Lecture 11-17

K-Means++ Can we prevent arbitrarily bad local minima? 1. Randomly choose first center. 2. Pick new center with prob. proportional to (Contribution of x to total error) 3. Repeat until K centers. ( x c i ) 2 Expected error ( ) = O log K * optimal Arthur & Vassilvitskii 2007 Slide credit: Steve Seitz Lecture 11-18

Feature Space Depending on what we choose as the feature space, we can group pixels in different ways. Grouping pixels based on intensity similarity Feature space: intensity value (1D) Slide credit: Kristen Grauman Lecture 11-19

Feature Space Depending on what we choose as the feature space, we can group pixels in different ways. Grouping pixels based on color similarity B G R=255 G=200 B=250 R=245 G=220 B=248 Feature space: color value (3D) R R=15 G=189 B=2 R=3 G=12 B=2 Slide credit: Kristen Grauman Lecture 11-20

Feature Space Depending on what we choose as the feature space, we can group pixels in different ways. Grouping pixels based on texture similarity F 1 F 2 Filter bank of 24 filters F 24 Feature space: filter bank responses (e.g., 24D) Slide credit: Kristen Grauman Lecture 11-21

Smoothing Out Cluster Assignments Assigning a cluster label per pixel may yield outliers: Original Labeled by cluster center s intensity How can we ensure they are spatially smooth? 1 2? 3 Slide credit: Kristen Grauman Lecture 11-22

Segmentation as Clustering Depending on what we choose as the feature space, we can group pixels in different ways. Grouping pixels based on intensity+position similarity Intensity Y X Þ Way to encode both similarity and proximity. Slide credit: Kristen Grauman Lecture 11-23

K-Means Clustering Results K-means clustering based on intensity or color is essentially vector quantization of the image attributes Clusters don t have to be spatially coherent Image Intensity-based clusters Color-based clusters Image source: Forsyth & Ponce Lecture 11-24

K-Means Clustering Results K-means clustering based on intensity or color is essentially vector quantization of the image attributes Clusters don t have to be spatially coherent Clustering based on (r,g,b,x,y) values enforces more spatial coherence Image source: Forsyth & Ponce Lecture 11-25

How to evaluate clusters? Generative How well are points reconstructed from the clusters? Discriminative How well do the clusters correspond to labels? Can we correctly classify which pixels belong to the panda? Note: unsupervised clustering does not aim to be discriminative as we don t have the labels. Lecture 11-26 Slide: Derek Hoiem

How to choose the number of clusters? Try different numbers of clusters in a validation set and look at performance. Lecture 11-27 Slide: Derek Hoiem

K-Means pros and cons Pros Finds cluster centers that minimize conditional variance (good representation of data) Simple and fast, Easy to implement Cons Need to choose K Sensitive to outliers Prone to local minima All clusters have the same parameters (e.g., distance measure is nonadaptive) *Can be slow: each iteration is O(KNd) for N d-dimensional points Usage Unsupervised clustering Rarely used for pixel segmentation Lecture 11-28

What will we learn today? K-means clustering Mean-shift clustering Reading: [FP] Chapters: 14.2, 14.4 D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature Space Analysis, PAMI 2002. Lecture 11-29

Mean-Shift Segmentation An advanced and versatile technique for clusteringbased segmentation 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: Svetlana Lazebnik Lecture 11-30

Mean-Shift Algorithm Iterative Mode Search 1. Initialize random seed, and window W 2. Calculate center of gravity (the mean ) of W: 3. Shift the search window to the mean 4. Repeat Step 2 until convergence Slide credit: Steve Seitz Lecture 11-31

Mean-Shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel Lecture 11-32 Mean Shift vector

Mean-Shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel Lecture 11-33 Mean Shift vector

Mean-Shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel Lecture 11-34 Mean Shift vector

Mean-Shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel Lecture 11-35 Mean Shift vector

Mean-Shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel Lecture 11-36 Mean Shift vector

Mean-Shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel Lecture 11-37 Mean Shift vector

Mean-Shift Region of interest Center of mass Slide by Y. Ukrainitz & B. Sarel Lecture 11-38

Real Modality Analysis Tessellate the space with windows Run the procedure in parallel Lecture 11-39 Slide by Y. Ukrainitz & B. Sarel

Real Modality Analysis The blue data points were traversed by the windows towards the mode. Slide by Y. Ukrainitz & B. Sarel Lecture 11-40

Mean-Shift Clustering Cluster: all data points in the attraction basin of a mode Attraction basin: the region for which all trajectories lead to the same mode Slide by Y. Ukrainitz & B. Sarel Lecture 11-41

Mean-Shift Clustering/Segmentation Find features (color, gradients, texture, etc) Initialize windows at individual pixel locations Perform mean shift for each window until convergence Merge windows that end up near the same peak or mode Slide credit: Svetlana Lazebnik Lecture 11-42

Mean-Shift Segmentation Results http://www.caip.rutgers.edu/~comanici/mspami/mspamiresults.html Lecture 11-43 Slide credit: Svetlana Lazebnik

More Results Slide credit: Svetlana Lazebnik Lecture 11-44

More Results Lecture 11-45

Problem: Computational Complexity Need to shift many windows Many computations will be redundant. Slide credit: Bastian Leibe Lecture 11-46

Speedups: Basin of Attraction 1. Assign all points within radius r of end point to the mode. r Slide credit: Bastian Leibe Lecture 11-47

Speedups r =c 2. Assign all points within radius r/c of the search path to the mode -> reduce the number of data points to search. Slide credit: Bastian Leibe Lecture 11-48

Technical Details Lecture 11-49 Comaniciu & Meer, 2002

Technical Details Term1: this is proportional to the density estimate at x (similar to equation 1 from the previous slide). Term2: this is the mean-shift vector that points towards the direction of maximum density. Comaniciu & Meer, 2002 Lecture 11-50

Technical Details Finally, the mean shift procedure from a given point x t is: 1. Computer the mean shirt vector m: 2. Translate the density window: 3. Iterate steps 1 and 2 until convergence. Lecture 11-51 Comaniciu & Meer, 2002

Summary Mean-Shift Pros General, application-independent tool Model-free, does not assume any prior shape (spherical, elliptical, etc.) on data clusters Just a single parameter (window size h) h has a physical meaning (unlike k-means) Finds variable number of modes Robust to outliers Cons Output depends on window size Window size (bandwidth) selection is not trivial Computationally (relatively) expensive (~2s/image) Does not scale well with dimension of feature space Slide credit: Svetlana Lazebnik Lecture 11-52

What will we have learned today K-means clustering Mean-shift clustering Reading: [FP] Chapters: 14.2, 14.4 D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature Space Analysis, PAMI 2002. Lecture 11-53