snakes - active contour

72
Snakes - Active Contour By: Saar Arbel cturer: Hagit Hel-Or

Upload: courtney

Post on 23-Feb-2016

81 views

Category:

Documents


0 download

DESCRIPTION

Snakes - Active Contour. By: Saar Arbel. Lecturer : Hagit Hel-Or. What is our objective?. To find a contour that best approximates the perimeter of an object. Subdividing or partitioning an image into its constituent regions or objects. But Wait. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Snakes - Active Contour

Snakes - Active Contour

By: Saar Arbel

Lecturer: Hagit Hel-Or

Page 2: Snakes - Active Contour

What is our objective?

To find a contour that best approximates the perimeter of an object

Its just like segmentation and many other methods...

Subdividing or partitioning an image into its constituent regions or objects

But Wait...

Page 3: Snakes - Active Contour
Page 4: Snakes - Active Contour

Problem with other methods Not effective in presence of noise and sampling artifacts (e.g. medical images).

This is done with segmentation on a noisy image

Page 5: Snakes - Active Contour

This is done with snakes on a noisy image

Page 6: Snakes - Active Contour

What is a snake?A framework for drawing an object outline from a possibly noisy 2D image.

An energy-minimizing curve guided by external constraint forces and influenced by image forces that pull it towards features (lines, edges).

Represents an object boundary or some other salient image feature as a parametric curve

Page 7: Snakes - Active Contour
Page 8: Snakes - Active Contour

Snakes are autonomous and self-adapting in their search for a minimal energy state

So... Why snakes?

They can be easily manipulated using external image forces

They can be used to track dynamic objects in temporal as well as the spatial dimensions

Page 9: Snakes - Active Contour
Page 10: Snakes - Active Contour

ApplicationsObject tracking

Shape recognition

Segmentation

Edge detection

Segmentation example

Page 11: Snakes - Active Contour

Aspects we need to considerRepresentation of the contours

Defining the energy functions- Internal- External

Minimizing the energy function

Page 12: Snakes - Active Contour

How is a snake represented?A Snake is represented as a set of points (x,y) that defines a function V(s).

Page 13: Snakes - Active Contour

Every snake include:External Energy Function

Internal Energy Function

A set of k points (in the discreet world)or a continuous function that will represent the points

Page 14: Snakes - Active Contour

The Energy functionsThe Snake's energy functions measure the appropriateness of the contour

Good solutions correspond to the minimum of the energy functions

Our goal is to minimize this function with respect to the contour parameters

Getting the snake closer to the target

In charge of the snake curvature and smoothness

Page 15: Snakes - Active Contour

A brief example:

Page 16: Snakes - Active Contour

The Energy functions

Our goal is to find a function V that will minimize E and give us a perfect match

Page 17: Snakes - Active Contour

You can think about the energy function like a heuristic function, they are similar because they both lead to a solution in a way that lets the programmer decide what is important and what’s not.

Intuitive tip

Page 18: Snakes - Active Contour

Forces the contour to be continuous

Decide if the snake wants to shrink/expand

Forces the contour to be smooth

Internal Energy

Econt Ecurv

Page 19: Snakes - Active Contour

Econt

Minimizing the first derivative has two effects:

The snake wants to shrink

Forces the contour to be continuous

The squaring of the differences causes the differences to be as similar as possible (the points are at equal distances from each other)

Page 20: Snakes - Active Contour

On the continuous world:

On the discrete world:The contour is approximated by N points P1, P2, . .., Pn and the first derivative is approximated by a finite difference:

Page 21: Snakes - Active Contour

Example

The points are equi-distances

The points arenot equi-distances

Page 22: Snakes - Active Contour

Ecurv

Forces the contour to be smooth.By taking the second derivative which represent the difference of the differences between 2 consecutive differences.This 2 consecutive differences represent the curvature and we want to penalize if the curvature is too high.

Page 23: Snakes - Active Contour

On the continuous world:

On the discrete world:The curvature can be approximated by the following finite difference:

Page 24: Snakes - Active Contour

Example: compare curvature

That’s better!

Page 25: Snakes - Active Contour

α,β meaning

We can play with α,β and to control the relation between the first derivative and the second derivative and get different results

Reminder:

Page 26: Snakes - Active Contour

Increase the internal energy of the snake as it stretches more and more

Small alpha make the energy function insensitive to the amount of stretch

Small α Big α

Page 27: Snakes - Active Contour

When beta is large then high price for curvature so snake prefers to be smooth and not curving

Small β

Small beta causes snake to allow large curvature so that snake will curve into bends in the contour

Big β

Page 28: Snakes - Active Contour

Internal energy - Summary

On the continuous world:

On the discrete world:

Page 29: Snakes - Active Contour

(X0 , Y0)

(X3 , Y3)

(X14 , Y14)

10),( niyx iii

Discrete representationRepresent the snake with a set of n points

Page 30: Snakes - Active Contour

Open and close snake

closed snake

n 0

open snake

0

1n

Dealing with open snake is easier and our algorithm will run faster (soon…)

Page 31: Snakes - Active Contour

External Energy – The Energy map

The energy map’s task is to emphasize the areas of the contour and to weaken the other areas of the image by creating a new image. By doing this we can attract our snake near the “emphasized” pixels which represent the contour of the image.

An energy map is a function f (x, y) that we extract from the image – I(x, y)

Page 32: Snakes - Active Contour

How do we build an Energy map?

By given an image – I(x, y) , we can build an energy map – f(x, y), that will attract our snake to edges on our image.For each pixel we will do:

By doing this we can easily locate the edges on the images because the gradient there is big.

(color image)

(black-white image)

Page 33: Snakes - Active Contour
Page 34: Snakes - Active Contour

ImageEnergy map

Page 35: Snakes - Active Contour

External Energy

Attracts the contour towards the closest image edge with dependence on the energy map. determines whether the snake feels attracted to object boundaries

Page 36: Snakes - Active Contour

Initial state Final state

Intuitive example

Page 37: Snakes - Active Contour

Eexternal

In order to make snakes useful for early vision we need energy functions that attract them to salient features in images.

I will present you 2 different energy functions which attract a snake to lines & edges.

Page 38: Snakes - Active Contour

Eline

Depending on the sign of Wline the snake will be attracted either to bright lines or dark lines.

Page 39: Snakes - Active Contour

Eedge

Reminder: Gradient is a generalization of the usual concept of derivative to the functions of several variables

Page 40: Snakes - Active Contour

Clarification

Note: As long as the points on the snake are closer to the edge (where the gradient is bigger) and then the Eedge is smaller, so that’s a good thing because that's how the external energy works! this gets the snake closer and closer to the target contour.

Page 41: Snakes - Active Contour

Examle

Image

External forceZoomed in

Page 42: Snakes - Active Contour

External energy - Summary

On the continuous world:

On the discrete world:

Page 43: Snakes - Active Contour

Example – External energy

Page 44: Snakes - Active Contour

How to find the optimal function V?

Several algorithms have been proposed to fit deformable contours.

We’ll look at two: -  Greedy search -  Dynamic programming (for 2d snakes)

Page 45: Snakes - Active Contour

Greedy algorithmA greedy algorithm makes locally optimal choices, hoping that the final solutionwill be globally optimal.

For each point of the snake, we search a window around it (window size: m) and move to where the energy function is minimal.

We will stop after enough points have not changed in the last iteration

Page 46: Snakes - Active Contour

Energy function for each point in the local neighborhood is calculated

The point is moved to the next point with lowest energy function

This process is repeated for every point

Iteration is done until termination condition met

Defined number of iterations

Points are calculates by an iterative process:

)( nmOComplexity:

Page 47: Snakes - Active Contour

But...Convergence not guaranteed!!Need decent initialization

Works very well as far as the initial snake is not too far from the desired solution

Page 48: Snakes - Active Contour
Page 49: Snakes - Active Contour

Viterbi algorithmDynamic programming algorithmWe need to make the snake discrete in order to use the algorithm

The discretization of the external energy depends on the particular energy term but the internal energy is always the same and can be discretized as follows:

Page 50: Snakes - Active Contour

Our problem is to finding the set of vertex positions V that minimizes:

Page 51: Snakes - Active Contour

We will now make the assumptionthat the snake is open and that β=0

In most cases, snake energy can be rewritten as a sum of pair-wise interaction potential:

(The internal energy is a local property of neighboring vertices)

Page 52: Snakes - Active Contour

),(...),(),(),...,,( 1132221121 nnnn vvEvvEvvEvvvE

1iE iEThis means that each vertex position Vi influences the total energy only through the terms and

Each vertex has m possible moves

Page 53: Snakes - Active Contour

We now define n variables (i=2,3,…,n)iS

Each contains the lowest total energy for the first k-1 vertices of the snake for a givenvalue of . Thus the minimum energy E of the whole snake is equal to

)( kk vS

kv)(min )( nnn vsv

Page 54: Snakes - Active Contour

The globally best position for the snake is therefore computed by first computing all the , so we determine at each node the optimal position of its predecessor for each possible location of the node.

kS

When we have computed we can find the optimal position for by minimizing the expression Once we know the position of the last node we look up the optimal position for the second last node and soon until we have determined the optimal position for all the nodes.

nSnu )( nn us

Page 55: Snakes - Active Contour

),( 44 nvvE),( 433 vvE

)3(3E

)4(3E )4(4E

)3(4E

)2(4E

)1(4E

)4(nE

)3(nE

)2(nE

)1(nE

)2(3E

)1(3E

)4(2E

)3(2E

),( 322 vvE

)1(2E

)2(2E

),( 211 vvE

)( 2nmOComplexity:

0)1(1 E

0)2(1 E

0)3(1 E

0)4(1 E

states

1

2

m

sites

1v 2v 3v 4v nv

Page 56: Snakes - Active Contour

Now, β≠0If β≠0 then the decomposition of the energy function into local terms becomes:

1iE,iE

This means that each vertex position Vi influences the total energy only through the terms and 1iE

Page 57: Snakes - Active Contour

And now we will define again n variables (i=2,3,…,n)iS

Note that we have to compute a table of values at each node instead of only m values per node for the simpler snakes with β=0.

2m

)( 3nmOComplexity:

Page 58: Snakes - Active Contour

Now, the snake is closed

Solution:1. Can use Viterbi to optimize snake energy in case v1 = c is fixed. (in this case the energy above effectively has no loop) 2. Use Viterbi to optimize snake for all possible values of c and choose the best of the obtained m solutions.

)( 3nmOComplexity:

1n

2

1n

3 4

Page 59: Snakes - Active Contour
Page 60: Snakes - Active Contour

Snakes - Pros Vs. ConsPros:

Snakes optimize globally.

Snakes are 1-dimensional which means that we can reduce 2-dimensional optimizationproblems to 1-dimensional optimization problems.

Active contour models provide a unified solution to several image processing problems such as the detection of light and dark lines and edges.

Useful to track and fit non-rigid shapes.Flexibility in how energy function is defined.

Page 61: Snakes - Active Contour

Cons:

Must have decent initialization near true boundary, may get stuck in local minimum.

Parameters of energy function must be set well based on prior information.

Page 62: Snakes - Active Contour

ExtensionsWe will review two main applications of snakes:-  Snake splitting -  Snake expending

Page 63: Snakes - Active Contour

Snake SplittingProblem:Snakes including multiple objects can not always extract each of them individually (when initialize the contour wrong)

Solution:Using the split-and-merge contour model based on detecting self- and mutual-crossings of the contour.

The method:There is a single contour which surrounding all objects and then iteratively splits into multiple contours by cutting at self-crossing points for extracting multiple objects individually

Page 64: Snakes - Active Contour
Page 65: Snakes - Active Contour

Snake ExpandingThere is some cases when our snakes would need to expand in order to get close to the contour.

Page 66: Snakes - Active Contour

Problems:If there is no image force (F=0), the curve shrinks on itself and vanishes to a point.Often, due to noise, some isolated points are gradient maxima and can stop the curve when it passes by. We can get stuck inside a shape (if our image force=0) So we need the define new force for this cases:

Page 67: Snakes - Active Contour

Solution:

we add another force which makes the contour have a more dynamic behavior.You can think about our curve as a “Balloon” Force which inflate our snake

The new Force

Page 68: Snakes - Active Contour

Cool demonstrations

Page 69: Snakes - Active Contour
Page 70: Snakes - Active Contour

SummarySnakes include: - Two energy functions (Internal and External) - N points who represents a function V

Main problem:Finding an optimal function V that minimize the Energy function

Solved by:- Greedy algorithm- Viterbi algorithm

Page 71: Snakes - Active Contour

ReferencesM. Kass, A. Witkin, and D. Terzopoulos, "Snakes:Active contour models.“, International Journal ofComputer Vision. v. 1, n. 4, pp. 321-331, 1987.

1.

http://www.computing.edu.au/~jim/thesis/ivins02.pdf3.

Wikipedia – Active contour models (Snakes)2.

http://www.cse.unr.edu/~bebis/CS791E/Notes/DeformableContours.pdf

4.

http://www.cs.utexas.edu/~grauman/courses/378/handouts/snakes.pdf

5.

http://cs.gmu.edu/~kosecka/cs682/lect-snakes.pdf6.

Page 72: Snakes - Active Contour

Thank you