snakes: active contours - u-szeged.hukato/teaching/emm/02-snake.pdf · zoltanzoltan kato: phd...

18
Zoltan Zoltan Zoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on Variational Variational Variational and Level Set Methods in Image processing and Level Set Methods in Image processing and Level Set Methods in Image processing Snakes: Snakes: Active Contours Active Contours Zoltan Zoltan Kato Kato http://www.cab.u http://www.cab.u - - szeged.hu/~kato/variational/ szeged.hu/~kato/variational/

Upload: others

Post on 28-Dec-2019

44 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snakes:Snakes:Active ContoursActive ContoursZoltanZoltan KatoKato

http://www.cab.uhttp://www.cab.u--szeged.hu/~kato/variational/szeged.hu/~kato/variational/

Page 2: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

22ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

IntroductionIntroduction

Proposed by Proposed by Michael Michael KassKassAndrew Andrew WitkinWitkin

http://http://www.ri.cmu.edu/people/witkin_andrew.htmlwww.ri.cmu.edu/people/witkin_andrew.htmlDemetriDemetri TerzopoulosTerzopoulos

http://http://mrl.nyu.edu/~dtmrl.nyu.edu/~dt//

Snakes: Active Contour ModelsSnakes: Active Contour Models. . International Journal of Computer Vision, International Journal of Computer Vision, Vol. 1, pp 321Vol. 1, pp 321--331, 1988.331, 1988.

Page 3: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

33ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

What is a snake?What is a snake?

An energy minimizing An energy minimizing splinespline guided by external constraint guided by external constraint forces and pulled by image forces toward features:forces and pulled by image forces toward features:

Edge detectionEdge detectionSubjective contoursSubjective contoursMotion trackingMotion trackingStereo matchingStereo matching….….

Images taken from the GVF website: Images taken from the GVF website: http://http://iacl.ece.jhu.edu/projects/gvfiacl.ece.jhu.edu/projects/gvf//

Page 4: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

44ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake behaviorSnake behavior

A snake falls into the closest A snake falls into the closest locallocal energy energy minimum.minimum.

The local minima of the snake energy comprise The local minima of the snake energy comprise the set of alternative solutionsthe set of alternative solutionsA higher level knowledge is needed to choose A higher level knowledge is needed to choose the the „correct one”„correct one” from these solutionsfrom these solutions

HighHigh--level reasoninglevel reasoningUser interactionUser interaction

These highThese high--level methods can level methods can interactinteract with the with the contour model by pushing it toward an contour model by pushing it toward an appropriate local minimumappropriate local minimum

Page 5: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

55ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake behaviorSnake behavior

They rely on other mechanisms They rely on other mechanisms to place them to place them nearnear the desired the desired contour.contour.

The existence of such an The existence of such an initializerinitializer is is application dependent.application dependent.Even in the case of manual Even in the case of manual initialization, snakes are quite initialization, snakes are quite powerful in refining the user’s input.powerful in refining the user’s input.

Basically, snakes are trying to Basically, snakes are trying to match a deformable model to an match a deformable model to an image by means of energy image by means of energy minimization.minimization. Image taken from the GVF website: Image taken from the GVF website:

http://http://iacl.ece.jhu.edu/projects/gvfiacl.ece.jhu.edu/projects/gvf//

Page 6: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

66ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake energySnake energy

Parametric representation: Parametric representation: v(sv(s)=()=(x(s),y(sx(s),y(s))))

EEintint = internal energy due to bending. Serves to impose = internal energy due to bending. Serves to impose piecewise smoothness constraint.piecewise smoothness constraint.EEimageimage = image forces pushing the snake toward image = image forces pushing the snake toward image features (edges, etc…).features (edges, etc…).EEconcon = external constraints are responsible for putting = external constraints are responsible for putting the snake near the desired local minimum. It may come the snake near the desired local minimum. It may come from:from:

Higher level interpretationHigher level interpretationUser interaction, etc…User interaction, etc…

∫ ++=1

0int ))(())(())(( dssvEsvEsvEE conimagesnake

Page 7: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

77ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Internal energyInternal energy

The snake is a The snake is a controlled continuitycontrolled continuity splinesplineRegularizes the problemRegularizes the problem

The first order derivative The first order derivative vvss(s(s)) makes the makes the splinespline act like act like a a membrane membrane („elasticity”).(„elasticity”).The second order derivative The second order derivative vvssss(s(s)) makes it act like a makes it act like a thinthin--plate plate („rigidity”).(„rigidity”).αα(s(s)) andand ββ(s)(s) controls the relative importance of controls the relative importance of membrane and thinmembrane and thin--plate termsplate terms

Setting Setting ββ(s)=0(s)=0 for a point allows the snake to become secondfor a point allows the snake to become second--order discontinuous and develop a corner.order discontinuous and develop a corner.

2/)|)(|)(|)(|)(( 22int svssvsE sss βα +=

Page 8: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

88ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Image forcesImage forces

Attracts the snake to features (data term)Attracts the snake to features (data term)

lineslines: the simplest functional is the image : the simplest functional is the image intensity: intensity: EElineline==I(x,yI(x,y))

Depending on the sign of Depending on the sign of wwlineline, the snake will be , the snake will be attracted to the lightest or darkest attracted to the lightest or darkest nerbynerby contour contour

edgesedges: one can simply set : one can simply set EEedgeedge= = -- ||∇∇ I(x,y)|I(x,y)|22

attracts the snake to large intensity gradients.attracts the snake to large intensity gradients.terminationsterminations: discussed later: discussed later

termtermedgeedgelinelineimage EwEwEwE ++=

Page 9: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

99ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake convergenceSnake convergence

If part of a snake finds a lowIf part of a snake finds a low--energy energy feature feature the the splinespline term will pull term will pull neighboring parts toward a possible neighboring parts toward a possible continuation of the feature found.continuation of the feature found.In fact, this places a large energy well In fact, this places a large energy well around a good local minimumaround a good local minimum

Video taken from the website: Video taken from the website: http://wwwhttp://www--2.cs.cmu.edu/afs/cs/user/aw/www/gallery.html2.cs.cmu.edu/afs/cs/user/aw/www/gallery.html

Page 10: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1010ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Scale spaceScale space

Minimization by scaleMinimization by scale--continuation:continuation:

1.1. Spatial Spatial smootingsmooting the edge or the edge or line functionalline functional

EEedgeedge= = --(G(Gσσ∗∇∗∇22 I)I)22, where , where GGσσ is is a Gaussian with a Gaussian with σσ standard standard deviationdeviationMinima lie on zero crossings Minima lie on zero crossings of of GGσσ∗∇∗∇22 I I (~edges)(~edges)

2.2. Snake comes to equilibrium on Snake comes to equilibrium on a blurry energya blurry energy

3.3. Slowly reduce the blurringSlowly reduce the blurringImage taken from Image taken from M. M. KassKass & A. & A. WitkinWitkin & D. & D. TerzopoulosTerzopoulos: Snakes: : Snakes: Active Contour Models. Active Contour Models. International Journal of Computer Vision, International Journal of Computer Vision, Vol. 1, pp 321Vol. 1, pp 321--331, 1988331, 1988..

Zero crossings

Page 11: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1111ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Termination functionalTermination functional

Attracts the snake toward termination of line Attracts the snake toward termination of line segments and corners. segments and corners.

Let Let C(x,yC(x,y)=)= GGσσ (x,y)(x,y)∗∗I(x,y))I(x,y))22 (smoothed image)(smoothed image)Let Let θθ=tan=tan--11(C(Cyy/C/Cxx)) the gradient anglethe gradient angle

n=(n=(coscos θθ, sin , sin θθ)) unit vector along gradientunit vector along gradientnn⊥⊥=(=(--sin sin θθ, , coscos θθ)) perpendicular to gradientperpendicular to gradient

EEtermterm is defined using curvature of level lines in is defined using curvature of level lines in C(x,yC(x,y))::

( ) 2/322

2222 2//

yx

yxxyxxyxyyterm

CC

CCCCCCCnCnC

nE

+

+−=

∂∂∂∂

=∂∂

= ⊥

θ

Page 12: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1212ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Subjective contourSubjective contour

Combining Combining EEedgeedge and and EEtermterm, we can create a snake , we can create a snake attracted to edges and terminationsattracted to edges and terminationsThe shape of the snake between the edges and lines in the The shape of the snake between the edges and lines in the illusion is completely determined by the illusion is completely determined by the splinespline smoothness smoothness termtermThe same snake can find traditional edges in natural The same snake can find traditional edges in natural imagesimages

Image taken from Image taken from M. M. KassKass & A. & A. WitkinWitkin & D. & D. TerzopoulosTerzopoulos: Snakes: : Snakes: Active Contour Models. Active Contour Models. International International Journal of Computer Vision, Vol. 1, Journal of Computer Vision, Vol. 1, pp 321pp 321--331, 1988331, 1988..

Page 13: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1313ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Subjective contour: Subjective contour: hysteresyshysteresys

Snake tracking a Snake tracking a moving subjective moving subjective contourcontourThe snake bends The snake bends until the internal until the internal splinespline forces forces overpower image overpower image forcesforcesThen the snake Then the snake falls off the line and falls off the line and returns to a returns to a smoother shapesmoother shape Image taken from Image taken from M. M. KassKass & A. & A. WitkinWitkin & D. & D. TerzopoulosTerzopoulos: Snakes: Active Contour Models. : Snakes: Active Contour Models. International International

Journal of Computer Vision, Vol. 1, pp 321Journal of Computer Vision, Vol. 1, pp 321--331, 1988331, 1988..

Page 14: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1414ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Motion trackingMotion tracking

Once a snake finds a Once a snake finds a feature, it „locks on”feature, it „locks on”If the feature begins If the feature begins to move, the snake to move, the snake will track the same will track the same local minimumlocal minimum

Fast motion could Fast motion could cause the snake to cause the snake to flip into a different flip into a different minimumminimum

Image taken from Image taken from M. M. KassKass & A. & A. WitkinWitkin & D. & D. TerzopoulosTerzopoulos: Snakes: Active Contour Models. : Snakes: Active Contour Models. International International Journal of Computer Vision, Vol. 1, pp 321Journal of Computer Vision, Vol. 1, pp 321--331, 1988331, 1988..

Page 15: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1515ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake energy minimizationSnake energy minimization

When When αα(s(s)) andand ββ(s)(s) are are constantconstant, we get two , we get two independent Eulerindependent Euler--Lagrange equations.Lagrange equations.When When αα(s(s)) andand ββ(s)(s) are not constantare not constant then then it is simpler to use a discrete formulation:it is simpler to use a discrete formulation:

0

0

=∂

∂++

=∂

∂++

yEyy

xExx

extssssss

extssssss

βα

βα

4211

221int

1int

2/|2|2/||)(

))(),((),(),()(

hvvvhvviE

ihyihxyxviEiEE

iiiiiii

iii

n

iextsnake

+−−

=

+−+−=

==+=∑βα

Page 16: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1616ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake energy minimizationSnake energy minimization

Let Let ffxx(i(i) = ) = ∂∂ EEextext //∂∂ xxiiwhere derivatives are where derivatives are approximated by finite approximated by finite differences if they differences if they cannot be computed cannot be computed analiticallyanalitically. . The corresponding The corresponding Euler equationsEuler equationsIn matrix form where In matrix form where AAis a is a pentadiagonalpentadiagonalbanded matrix:banded matrix:

0))(),(()2()2(2)2(

)()(

211

11

121

111

=++−++−−+−+

−−−

+++

+−

−−−

++−

ififvvvvvvvvv

vvvv

yx

iiii

iiii

iiii

iiiiii

βββ

αα

0),(0),(

=+=+

yxfAyyxfAx

y

x

Page 17: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1717ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake energy minimizationSnake energy minimization

Taking into account the derivatives requires Taking into account the derivatives requires changing changing AA at each iteration. Speed up:at each iteration. Speed up:

We assume that We assume that ffxx and and ffyy are constant during a are constant during a time step time step explicit Euler method explicit Euler method w.r.tw.r.t. the . the external forces.external forces.internal forces are specified by internal forces are specified by AA we can we can evaluate the time derivative at evaluate the time derivative at tt rather than rather than tt--11

)(),()(),(

111

111

−−−

−−−

−−=+−−=+

ttttyt

ttttxt

yyyxfAyxxyxfAx

γγ

γ is the step size

Page 18: Snakes: Active Contours - u-szeged.hukato/teaching/emm/02-Snake.pdf · ZoltanZoltan Kato: PhD Course on Kato: PhD Course on VariationalVariational and Level Set Methods in Image processingand

1818ZoltanZoltanZoltan Kato: PhD Course on Kato: PhD Course on Kato: PhD Course on VariationalVariationalVariational and Level Set Methods in Image processingand Level Set Methods in Image processingand Level Set Methods in Image processing

Snake energy minimizationSnake energy minimization

At equilibrium, the time derivative vanishes.At equilibrium, the time derivative vanishes.The Euler equations can be solved by The Euler equations can be solved by matrix inversion:matrix inversion:

The inverse can be calculated by The inverse can be calculated by LULUdecomposition in decomposition in O(nO(n)) time.time.

)),(()(

)),(()(

1111

1111

−−−−

−−−−

−+=

−+=

ttytt

ttxtt

yxfyIAyyxfxIAx

γγ

γγ