Docsity

Template Matching: Finding the Best Match between Patterns, Slides of Machine Learning

Toggle sidebar
bg1
1
TEMPLATE MATCHING
The Goal: Given a set of reference patterns
known as TEMPLATES,findtheonetowhichan
unknown pattern matches best. That is, each
class is represented by a single typical pattern.
The crucial point is to adopt an appropriate
“measure” to quantify similarity or matching.
These measures must accommodate, in an
efficient way, deviations between the template
and the test pattern. For example, the word
beauty may have been read a beeauty or beuty,
etc., due to errors.
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Template Matching: Finding the Best Match between Patterns and more Slides Machine Learning in PDF only on Docsity!

1

TEMPLATE MATCHING

The Goal:

Given a set of reference patterns

known as TEMPLATES, find the one to which anunknown pattern matches best.

That is, each

class is represented by a single typical pattern. 

The

crucial

point

is

to

adopt

an

appropriate

“measure” to quantify similarity or matching. 

These

measures

must

accommodate,

in

an

efficient way, deviations between the templateand the test pattern.

For example, the word

beauty may have been read a beeauty or beuty,etc., due to errors.

2

Typical Applications

Speech Recognition 

Motion Estimation in Video Coding 

Data Base Image Retrieval 

Written Word Recognition 

Bioinformatis

Measures based on optimal path searchingtechniques

Representation:

Represent the template by a

sequence of measurement vectorsTemplate:Test pattern:

(^
I

r

r

r

1 (^

J

t

t

t

4

Path:

A path through the grid, from an initial node

(i

0

, j

) 0 to a final one

(

if^

, j

),f

is an ordered set of nodes

(i

0

, j

) 0 ,^

(i

1

, j

) 1 ,^

(i

2

, j

) 2 …

(

i^ k

, j

)k …

(

i^ f^

, j

) .f

Each

path

is

associated

with

a

cost

where

K

is the number of nodes across the path.

  

(^10)

K k

k k^

j i d

D

5

Search for the path with the optimal cost

D

opt.

The matching cost between template

and test

pattern

is

D

opt.

r

t

7

Bellman’s Principle: 

In words:

The overall optimal path from

i^0

,j

to

(i

f^

,j

)f

through

(i,j

)^

is

the

concatenation

of

the

optimal paths from

(i

0

,j

to

(i,j

)^

and from

(i,j

)^

to

(i

,jf

).f

Let

D

opt.

i,j

)^

is the optimal path to reach

i,j

)^

from

(i

0

,j

,^

then

Bellman’s

principle

is

expressed

mathematically

as:

(^

0 0

0 0

f

f

opt

opt

f

f

opt

j i

j i

j i j i j i j i

8

(^

1

1

k

k

k

k

opt

k

k

opt

j i d j i D

opt

j

i

D

10

The cost is based on the philosophy behind theso-called variational similarity, i.e.,

Measure the cost associated with converting onepattern to the other

Edit distance:

Minimal

total number of changes,

C

, insertions

I

and deletions

R
,^

required to change

pattern

A

into pattern

B

where

j

runs over All possible variations of

symbols, in order to

convert

A
)]( B

) (

) ( [

min ) , (^

j R j I j C B A D

j^

11

Allowable predecessors and costs

Horizontal 

Vertical

(^

j

i

j

i^

if

if

(^

j

r

i

t

j r i t j i j i d

(^

j

i

j

i

d

1

) 1

,

, (^

  j i j i d

13

Examples:

14

T

he Algorithm 

D

(0,

)=

For i=1, to I

-^

D

(i,

)=D

(i-1,

)+

END

{

FOR

}

For j=1 to J

-^

D

(0,j

)=D

(0,j-

)+

END

{FOR

}

For i=1 to I

-^

For j=1, to J

C

=D 1

(i-1,j-

)+d

(i,j

׀

i-1,j-

)

C

=D 2

(i-1,j

)+

C

=D 3

(i,j-

)+

D

(i,j

)=min

(

C

,C 1

,C 2

) 3

-^

END {FOR

}

END

{

FOR

}

D
(A,B)=D
(I,J

16

  • For each frame compute a feature vector. For example,

the DFT coefficients and use, say,

ℓ^

of those:

  • Cho

ο

se

a

cost

function

associated

with

each

node

across a path, e.g., the Euclidean distance

  • For each reference pattern compute the optimal path

and the associated cost, against the test pattern.

  • Match

the

test

pattern

to

the

reference

pattern

associated with the minimum cost.

, ..., I

i

x x x

i r

i i i

(^
, ..., J

j

x x x

j t

j j j

(^
(^

k k

k

k^

j i d j t i

r^

17

Prior to computing the path one has to choose:

  • The global constraints: Defining the region of space

within which the search for the optimal path will beperformed.

19

Measures based on Correlations: The major task here isto

find

whether

a

specific

known

reference

pattern

resides within a given block of data. Such problems arisein problems such as target detection, robot vision, videocoding. There are two basic steps in such a procedure:^ 

Step 1: Move the reference pattern to all possiblepositions within the block of data. For each position,compute

the

“similarity”

between

the

reference

pattern and the respective part of the block of data. 

Step 2: Compute the best matching value.

20

Application to images: Given a reference image,

r

(i,j

of

M

x

N

size, and

an

I

x

J^

image array

t

(i,j

Move

r

(i,j

to all possible positions

m,n

)^

within

t

(i,j

Compute:

for every

m,n

).

  • For all

(

m,n

)^

compute the minimum.

  • The above is equivalent, for most practical cases, to

compute the position

(

m,n

)^

for which the correlation is

maximum.

  • – Equivalently,

the

normalized

correlation

can

be

computed as

i^

j

n j m i r j i t n m D

2 ) , ( ) , ( ) , (

i^

j

n j m i r j i t n m

c^

) , ( ) , ( ) , (





i^

j

i^

j

N

j i r j i t

n m c

n m c^

2

2

) , ( ) , (

) , ( ) , (