mean shift segmentation - center for machine perception...

15
Mean Shift Segmentation Jan Kybic winter semester 2007

Upload: lydieu

Post on 22-May-2018

217 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean Shift Segmentation

Jan Kybic

winter semester 2007

Page 2: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift segmentation overview

I No assumptions about probability distributions — rarelyknown

I Spatial-range domain(x , y , f (x , y)

)— normally f (x , y)

I Find maxima in the(x , y , f

)space — clusters close in space

and range correspond to classes.

Page 3: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift procedure

Goal: Find local maxima of the probability density (density modes)given by samples.

Initial window

New window

New

centro

id

Old ce

ntro

id

Mean shift

1. Start with a random region of interest.

2. Determine a centroid of the data.

3. Move the region to the location of the new centroid.

4. Repeat until convergence.

Page 4: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Kernel estimation

K (x) = ckk(‖x‖2

)(radial symmetry)

Epanechnikov kernel (other choices possible)

k(r) =

{1− r for r ≤ 1

0 otherwise(profile, r = ‖x‖2)

Kernel density estimator

f̃ (x) =1

n hd

n∑i=1

K

(x− xi

h

)

Page 5: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift procedure

At density maxima ∇f̃ = 0

f̃ (x) =1

n hd

n∑i=1

K

(x− xi

h

)

∇f̃ (x) =2 ck

n h(d+2)

n∑i=1

(x− xi ) k ′

(∣∣∣∣∣∣∣∣x− xi

h

∣∣∣∣∣∣∣∣2)

=2 ck

n h(d+2)

(n∑

i=1

gi

) (∑ni=1 xi gi∑ni=1 gi

− x

)

for g(r) = k ′(r), gi = g(||(x− xi )/h||2

)

Page 6: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift procedure

At density maxima ∇f̃ = 0

f̃ (x) =1

n hd

n∑i=1

K

(x− xi

h

)

0 = ∇f̃ (x) =2 ck

n h(d+2)

n∑i=1

(x− xi ) k ′

(∣∣∣∣∣∣∣∣x− xi

h

∣∣∣∣∣∣∣∣2)

=2 ck

n h(d+2)

(n∑

i=1

gi

) (∑ni=1 xi gi∑ni=1 gi

− x

)︸ ︷︷ ︸

mean shift vector — must be 0 at optimum

for g(r) = k ′(r), gi = g(||(x− xi )/h||2

)

Page 7: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift procedure (2)

Mean shift vector

m(x) =

∑ni=1 xi gi∑ni=1 gi

− x

gi = g(||(x− xi )/h||2

)g(r) = k ′(r)

Successive locations yj of the kernel:

yj+1 =n∑

i=1

xi g

(∣∣∣∣∣∣∣∣yj − xi

h

∣∣∣∣∣∣∣∣2)/ n∑

i=1

g

(∣∣∣∣∣∣∣∣yj − xi

h

∣∣∣∣∣∣∣∣2)

Page 8: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift procedure (2)

Mean shift vector

m(x) =

∑ni=1 xi gi∑ni=1 gi

− x

gi = g(||(x− xi )/h||2

)g(r) = k ′(r)

Successive locations yj of the kernel:

yj+1 =n∑

i=1

xi g

(∣∣∣∣∣∣∣∣yj − xi

h

∣∣∣∣∣∣∣∣2)/ n∑

i=1

g

(∣∣∣∣∣∣∣∣yj − xi

h

∣∣∣∣∣∣∣∣2)

Theorem: If k is convex and monotonically decreasing, thesequence

{yj

}j=1,2,...

converge and{f̃ (yj)

}j=1,2,...

increasesmonotonically.

For Epanechnikov kernel → convergence in finite number of steps.

Page 9: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift mode detection

Points from a basin of attraction converge to the same mode.

Algorithm:

1. Using multiple initializations covering the entire feature space,identify modes (stationary points).

2. Using small random perturbation, retain only local maxima.

Page 10: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift mode detection example

20 30 40 50 60 70 80 90 100−20

0

20

40

60

80

100

L*

u*

20 30 40 50 60 70 80 90 100−20

0

20

40

60

80

100

L*

u*

Page 11: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift discontinuity preserving filtering

Combine spatial and range values

K (x) = ([xs xr ]) =c

hds hp

rk

(∣∣∣∣∣∣∣∣xs

hs

∣∣∣∣∣∣∣∣2)

k

(∣∣∣∣∣∣∣∣xr

hr

∣∣∣∣∣∣∣∣2)

,

Algorithm:

1. For each image pixel xi , initialize yi ,1 = xi .

2. Iterate the mean shift procedure until convergence.

3. The filtered pixel values are defined as zi = (xsi , y

ri ,con); the

value of the filtered pixel at the location xsi is assigned the

image value of the pixel of convergence yri ,∞.

Page 12: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift discontinuity preserving filtering

Page 13: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift segmentation

1. Mean shift discontinuity preserving filtering

2. Determine the clusters {Cp}p=1,...,m by grouping all zi , whichare closer than hs in the spatial domain and hr in the rangedomain, i.e. merge the basins of attractions.

3. Assign class labels to clusters

4. If desired, eliminate regions smaller than P pixels.

Page 14: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift segmentation examples

Page 15: Mean Shift Segmentation - Center For Machine Perception …cmp.felk.cvut.cz/cmp/courses/33DZOzima2007/slidy/meanShiftSeg.pdf · Mean shift segmentation overview I No assumptions about

Mean shift segmentation examples