This presentation contains a review on template matching and shows its disadvantages compared to other flexible matching techniques like flexible shape matching and snake.
Find me on:
AFCIT
http://www.afcit.xyz
YouTube
https://www.youtube.com/channel/UCuewOYbBXH5gwhfOrQOZOdw
Google Plus
https://plus.google.com/u/0/+AhmedGadIT
SlideShare
https://www.slideshare.net/AhmedGadFCIT
LinkedIn
https://www.linkedin.com/in/ahmedfgad/
ResearchGate
https://www.researchgate.net/profile/Ahmed_Gad13
Academia
https://www.academia.edu/
Google Scholar
https://scholar.google.com.eg/citations?user=r07tjocAAAAJ&hl=en
Mendelay
https://www.mendeley.com/profiles/ahmed-gad12/
ORCID
https://orcid.org/0000-0003-1978-8574
StackOverFlow
http://stackoverflow.com/users/5426539/ahmed-gad
Twitter
https://twitter.com/ahmedfgad
Facebook
https://www.facebook.com/ahmed.f.gadd
Pinterest
https://www.pinterest.com/ahmedfgad/
6. Index
• Template Matching Overview
• Deformable Template
• Active Contour (Snake)
• Greedy Algorithm for Snake
17-Aug-166
7. Deformable Template –
Exact Match Solution
• Rather than using a fixed template with fixed
parameters, more flexible template is used.
17-Aug-167
8. Deformable Template –
Many Comparisons Solution
• Use only key edge points to detect object.
• These points are discriminant points of the object which are
edge points.
𝒓 𝟐
=(𝒙 − 𝑪 𝒄𝒙) 𝟐+(𝒚 − 𝑪 𝒄𝒚) 𝟐
17-Aug-168
9. Deformable Template –
Dynamic Templates Generation
• The set of parameter values that makes the template
best matches the edge points is the best parameters to
use.
{𝑪 𝒑, 𝒂, 𝒃, 𝒄, 𝑪 𝒄, r}
• Deformable templates may not be completely
autonomous.
17-Aug-169
10. Template Energy
• Good template parameters is what maximizes the
energy.
• The goal is to find parameters that maximize 𝑬 𝒆.
17-Aug-1612
11. More Parameters
• More parameters can be used to make results more
accurate.
• By a little eye analysis, it is apparent that usually sclera
is white and iris is darker than it.
• Adding these parameters can enhance results.
Sclera Iris
17-Aug-1613
12. Combine Parameters
• Combining all parameters, result in this final energy.
• Where 𝑪 𝒆, 𝑪 𝒗, 𝑪 𝒑 are weighting parameters that control
the influence of this parameter over the resultant energy.
• Goal is to maximize E.
17-Aug-1614
13. Many Parameters –
Problem
• For each parameter, there are a number of values that
needs to be tested until maximum energy reached.
• Say 11 parameters selected and each parameter can
have 100 values, so there are more than
𝟏𝟎 𝟐𝟓
combinations of parameter values needed to be
tested.
17-Aug-1615
14. Many Parameters –
Solution
• This problem can be solved in two ways:
o Optimization techniques that not reduce number
of combinations but try to make calculations quickly.
o Techniques to reduce number of parameters such
as snakes.
17-Aug-1616
15. Index
• Template Matching Overview
• Deformable Template
• Active Contour (Snake)
• Greedy Algorithm for Snake
17-Aug-1617
16. • An active contour is a set of points that aims to enclose a
target object.
Active Contour : Snake
17-Aug-1618
17. Active Contour : Snake
• Contour is a bounding region of a target object.
• It is active because it is a self-learning process to modify
itself until closely bound the target object.
• Contour changes like a snake.
• Goal of snakes is to find salient image contours that
surround target object.
17-Aug-1619
18. Snake Spline
• Snake draws a contour surrounding the target object.
• There are many complex objects with complex
boundaries and multiple inflection points.
• Snake uses spline to be able to draw complex shapes
using simple shapes.
• Spline divides complex shapes into small segments that
are easier to graph.
17-Aug-1620
19. Spline
• Spline is a polynomial or a set of polynomials to
approximates complex shapes.
• Complex shapes has many inflection points that can
be divided into simple segments with fewer inflection
points.
• Because cubic polynomial has a maximum of only two
inflection points, it will be used to approximate complex
shapes.
17-Aug-1621
x(u)=𝒂 𝒙 𝒖 𝟑
+𝒃 𝒙 𝒖 𝟐
+𝒄 𝒙 𝒖 +𝒅 𝒙
y(u)=𝒂 𝒚 𝒖 𝟑
+𝒃 𝒚 𝒖 𝟐
+𝒄 𝒚 𝒖 +𝒅 𝒚
20. Spline
• Complex shapes are divided into segments of at most
two inflection points.
• These segments are approximated using the cubic
polynomial.
• Collection of segments are then connected together in a
smooth manner.
17-Aug-1622
21. Contour
• Contour is defined in terms of x and y of all spline cubic
polynomial inflection points used to approximate
complex shape.
𝒗 𝒔 = (𝒙 𝒔 , 𝒚 𝒔 )
17-Aug-1623
22. Snake Process
• Snake is similar to deformable templates in which they
may be semiautomatic.
• They rely on other mechanisms to place them near the
desired contour.
• User specify the initial contour and snake tries to modify
it to find optimal contour.
17-Aug-1624
23. Snake Energy Minimization
• Snake changes its contour using different forces:
o Internal forces
o Image forces
o External forces
• To judge contour optimality, snake uses energy
minimization techniques.
17-Aug-1625
24. Internal Forces –
Internal Energy
• Internal forces is used to modify the spline shape.
• Internal energy of spline is symbolized 𝑬𝒊𝒏𝒕 that just
depends on spline shape.
• It consists of first- and second-order terms of contour
points.
17-Aug-1626
25. Internal Forces Energy
• Internal energy has two parameters that control snake
shape:
o α controls amount of snake spline stretching.
o β controls amount of snake spline flexing/smoothing.
• The larger α, the more stretch snake contour is.
• The larger β, the smoother snake contour.
17-Aug-1627
26. Image Forces
17-Aug-1628
• How a snake can know we need to detect eye?
• Image forces guides the snake to a selected image
portion with certain features.
• Examples is to depend on:
o Lines
o Edges
27. Image Forces Energy
• To measure image force optimality, image energy is
calculated.
• If only line and edge are the features to guide the snake,
thus line energy 𝑬𝒍𝒊𝒏𝒆 and edge energy 𝑬 𝒆𝒅𝒈𝒆 are
calculated.
• There are two parameters used to control image forces:
o 𝒘𝒍𝒊𝒏𝒆 guides snake to align itself to dark regions.
o 𝒘 𝒆𝒅𝒈𝒆guides snake to align itself to sharp edges.
17-Aug-1629
28. Index
• Template Matching Overview
• Deformable Template
• Active Contour (Snake)
• Greedy Algorithm for Snake
17-Aug-1631
29. Greedy Algorithm for
Snakes
• Greedy algorithm implements the snake energy
minimization.
17-Aug-1632
Define snake parameters α,β, 𝒘𝒍𝒊𝒏𝒆
and 𝒘 𝒆𝒅𝒈𝒆
Select snake point
Check neighborhood points for
lower energy
Set new snake point to new
minimum
30. Greedy Algorithm -
Initialization
• Snake parameters are initialized
externally and initial contour is found.
• Say there are 10 points in the initial
contour, then Greedy algorithm will
be applied on all10 points.
17-Aug-1633
Define snake parameters α,β, 𝒘𝒍𝒊𝒏𝒆
and 𝒘 𝒆𝒅𝒈𝒆
31. Greedy Algorithm – Snake
Point Neighborhood
17-Aug-1634
After Iteration 1After Iteration 2After Iteration 3