24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5....

41
Mean Shift Wednesday, 06/05/2020 Antonis Argyros e-mail: [email protected]

Transcript of 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5....

Page 1: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Mean Shift

Wednesday, 06/05/2020

Antonis Argyrose-mail: [email protected]

Page 2: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Mean shift clustering and segmentation

• An advanced and versatile technique for

clustering-based segmentation

D. Comaniciu and P. Meer, Mean Shift: A Robust Approach toward Feature

Space Analysis, PAMI 2002.

Page 3: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

What is Mean Shift ?

PDF in feature space

• Color space

• …

• Actually any feature space you can conceive

A tool for:

Finding modes in a set of data samples, manifesting an

underlying probability density function (PDF) in RN

Page 4: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Intuitive Description

Distribution of identical billiard balls

Region of

interest

Center of

mass

Mean Shift

vector

Objective : Find the densest region

Page 5: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Intuitive Description

Distribution of identical billiard balls

Region of

interest

Center of

mass

Mean Shift

vector

Objective : Find the densest region

Page 6: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Intuitive Description

Distribution of identical billiard balls

Region of

interest

Center of

mass

Mean Shift

vector

Objective : Find the densest region

Page 7: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Intuitive Description

Distribution of identical billiard balls

Region of

interest

Center of

mass

Mean Shift

vector

Objective : Find the densest region

Page 8: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Intuitive Description

Distribution of identical billiard balls

Region of

interest

Center of

mass

Mean Shift

vector

Objective : Find the densest region

Page 9: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Intuitive Description

Distribution of identical billiard balls

Region of

interest

Center of

mass

Mean Shift

vector

Objective : Find the densest region

Page 10: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Intuitive Description

Distribution of identical billiard balls

Region of

interest

Center of

mass

Objective : Find the densest region

Page 11: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

What is Mean Shift ?

Non-parametric

Density Estimation

Non-parametric

Density GRADIENT Estimation

(Mean Shift)

Data

Discrete PDF Representation

PDF Analysis

A tool for:

Finding modes in a set of data samples, manifesting an

underlying probability density function (PDF) in RN

Page 12: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Non-Parametric Density Estimation

Assumption : The data points are sampled from an underlying PDF

Assumed Underlying PDF Real Data Samples

Data point density

implies PDF value !

Page 13: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Assumed Underlying PDF Real Data Samples

Non-Parametric Density Estimation

Page 14: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Assumed Underlying PDF Real Data Samples

Non-Parametric Density Estimation

Page 15: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Parametric Density Estimation

Assumption : The data points are sampled from an underlying PDF

Assumed Underlying PDF

2

2

( )

2

i

PDF( ) =

i

i

ic e

x-μ

x

Estimate

Real Data Samples

Page 16: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Real Modality Analysis

Tessellate the space

with windowsRun the procedure in parallel

Page 17: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Real Modality Analysis

The blue data points were traversed by the windows towards the mode

Page 18: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Clustering

Attraction basin : the region for which all trajectories lead to the same mode

Cluster : All data points in the attraction basin of a mode

Mean Shift : A robust Approach Toward Feature Space Analysis, by Comaniciu, Meer

Page 19: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Mean Shift Mode Detection

Updated Mean Shift Procedure:

• Find all modes using the Simple Mean Shift Procedure

• Prune modes by perturbing them (find saddle points and plateaus)

• Prune nearby – take highest mode in the window

What happens if we

reach a saddle point

?

Perturb the mode position

and check if we return back

Page 20: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

ClusteringSynthetic Examples

Simple Modal Structures

Complex Modal Structures

Page 21: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

ClusteringReal Example

L*u*v space representation

Page 22: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

ClusteringReal Example

Initial window

centers

Modes found Modes after

pruning

Final clusters

Feature space:

L*u*v representation

Page 23: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

SegmentationExample

…when feature space is only

gray levels…

Page 24: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

SegmentationExample

Page 25: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

SegmentationExample

Page 26: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

SegmentationExample

Page 27: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

SegmentationExample

Page 28: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

SegmentationExample

Page 29: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

SegmentationExample

Page 30: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Mean-Shift Object TrackingTarget Representation

Choose a

reference

target model

Quantized

Color Space

Choose a

feature space

Represent the

model by its

PDF in the

feature space

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

1 2 3 . . . m

color

Pro

bab

ilit

yKernel Based Object Tracking, by Comaniniu, Ramesh, Meer

Page 31: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

,f p y q � �

Mean-Shift Object TrackingTarget Localization Algorithm

Start from the

position of the

model in the

current frame

q�

Search in the

model’s

neighborhood

in next frame

p y�

Find best

candidate by

maximizing a

similarity func.

Page 32: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Mean-Shift Object TrackingResults

Page 33: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Tracking Through Scale SpaceResults

Fixed-scale

Tracking through scale space

Page 34: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Mean shift

• Pros:– Does not assume shape on clusters

– One parameter choice (window size, aka “bandwidth”)

– Generic technique

– Find multiple modes

• Cons:– Selection of window size

– Does not scale well with dimension of feature space

Page 35: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Image Segmentation with Graph Cuts

Page 36: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

q

Images as graphs

• Fully-connected graph

– node (vertex) for every pixel

– link between every pair of pixels, p,q

– affinity weight wpq for each link (edge)

• wpq measures similarity

• similarity is inversely proportional to difference (in color and

position…)

p

wpq

w

Source: Steve Seitz

Page 37: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Segmentation by Graph Cuts

• Break Graph into Segments

– Want to delete links that cross between segments

– Easiest to break links that have low similarity (low weight)

• similar pixels should be in the same segments

• dissimilar pixels should be in different segments

w

A B C

Source: Steve Seitz

q

p

wpq

Page 38: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Measuring affinity

• One possibility:

Small sigma:

group only

nearby points

Large sigma:

group distant

points

Page 39: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Measuring affinity

σ=.1 σ=.2 σ=1

σ=.2

Data points

Affinity

matrices

Slide credit: Kristen Grauman

Page 40: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Cuts in a graph: Min cut

• Link Cut

– set of links whose removal makes a graph

disconnected

Cost of a cut:

AB

Find minimum cut• gives you a segmentation

• fast algorithms exist for doing this

Source: Steve Seitz

BqAp

qpwBAcut,

,),(

Page 41: 24 CV MeanShift-GCuts 0605users.ics.forth.gr/.../24_CV_MeanShift-GCuts_0605_01.pdf · 2020. 5. 6. · σ=.1 σ=.2 σ=1 σ=.2 Data points Affinity matrices Slide credit: Kristen Grauman.

Minimum cut

• Problem with minimum cut:

Weight of cut proportional to number of edges in the cut;

tends to produce small, isolated components.

J. Shi and J. Malik, Normalized Cuts and Image Segmentation, CVPR, 1997