Sie sind auf Seite 1von 15

Mean Shift Segmentation

Jan Kybic

winter semester 2007


Mean shift segmentation overview

I No assumptions about probability distributions — rarely


known

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.
Mean shift procedure

Goal: Find local maxima of the probability density (density modes)


given by samples.

New window
O
ld
ce
n
tro
id

N
ew
ce

Initial window
nt
ro
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.
Kernel estimation

K (x) = ck k kxk2

(radial symmetry)

Epanechnikov kernel (other choices possible)


(
1−r for r ≤ 1
k(r ) = (profile, r = kxk2 )
0 otherwise

Kernel density estimator


n  
1 X x − xi
f (x) =
e K
n hd h
i=1
Mean shift procedure

At density maxima ∇e
f =0

n  
1 X x − xi
f (x) =
e K
n hd h
i=1
n !
x − xi 2

2 c k
X
0
∇e
f (x) = (x − xi ) k
n h(d+2) i=1 h
n
! P
n 
2 ck X
i=1 xi gi
= gi Pn −x
n h(d+2) i=1 i=1 gi

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



Mean shift procedure

At density maxima ∇e
f =0

n  
1 X x − xi
f (x) =
e K
n hd h
i=1
n 2 !
2 c k
X x − x i
(x − xi ) k 0

0 = ∇e
f (x) = (d+2)
nh h
i=1
n
! P
n 
2 ck X
i=1 xi gi
= gi Pn −x
n h(d+2) i=1 i=1 gi
| {z }
mean shift vector — must be 0 at optimum

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



Mean shift procedure (2)

Mean shift vector


Pn
xi gi
m(x) = Pi=1 n −x
i=1 gi
gi = g ||(x − xi )/h||2


g (r ) = k 0 (r )

Successive locations yj of the kernel:

n n
!  X !
yj − xi 2 yj − xi 2

X
yj+1 = xi g g
h h
i=1 i=1
Mean shift procedure (2)

Mean shift vector


Pn
xi gi
m(x) = Pi=1 n −x
i=1 gi
gi = g ||(x − xi )/h||2


g (r ) = k 0 (r )

Successive locations yj of the kernel:


n n
!  X !
yj − xi 2 yj − xi 2

X
yj+1 = xi g
g
h h
i=1 i=1
Theorem: If k is convex and monotonically
 decreasing, the
sequence yj j=1,2,... converge and ef (yj ) j=1,2,... increases
monotonically.

For Epanechnikov kernel → convergence in finite number of steps.


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.
Mean shift mode detection example

100 100

80 80

60 60
u*

u*
40 40

20 20

0 0

−20 −20
20 30 40 50 60 70 80 90 100 20 30 40 50 60 70 80 90 100
L* L*
Mean shift discontinuity preserving filtering

Combine spatial and range values


s 2 ! r 2 !
s r c x x
K (x) = ([x x ]) = d p k k
hs

hr ,
hs hr

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 , yi,con
r ); the
s
value of the filtered pixel at the location xi is assigned the
image value of the pixel of convergence yi,∞r .
Mean shift discontinuity preserving filtering
Mean shift segmentation

1. Mean shift discontinuity preserving filtering


2. Determine the clusters {Cp }p=1,...,m by grouping all zi , which
are closer than hs in the spatial domain and hr in the range
domain, i.e. merge the basins of attractions.
3. Assign class labels to clusters
4. If desired, eliminate regions smaller than P pixels.
Mean shift segmentation examples
Mean shift segmentation examples

Das könnte Ihnen auch gefallen