real time pattern detection

54
1 Real Time Pattern Real Time Pattern Detection Detection Yacov Hel-Or The Interdisciplinary Center Hagit Hel-Or Haifa University

Upload: bin

Post on 05-Feb-2016

64 views

Category:

Documents


0 download

DESCRIPTION

Real Time Pattern Detection. Yacov Hel-Or The Interdisciplinary Center. Hagit Hel-Or Haifa University. Pattern Detection. A given pattern is sought in an image. The pattern may appear at any location in the image. The pattern may be subject to any transformation - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Real Time Pattern Detection

1

Real Time Pattern DetectionReal Time Pattern Detection

Yacov Hel-Or The Interdisciplinary Center

Hagit Hel-Or Haifa University

Page 2: Real Time Pattern Detection

A given pattern is sought in an image. • The pattern may appear at any location in the image.• The pattern may be subject to any transformation (within a given transformation group).

Pattern Detection

• • •

Page 3: Real Time Pattern Detection

Face detection in images

Example

Page 4: Real Time Pattern Detection

Why is it Expensive? The search in Spatial Domain

Searching for faces in a 1000x1000 image, is applied 1e6 times, for each pixel location.

A very expensive search problem

Page 5: Real Time Pattern Detection

• A pattern under transformations draws a very complex manifold in “pattern space”:

– In a very high dimensional space.

– Non convex.

– Non regular (two similarly perceived patterns may be distant in pattern space).

Why is it difficult? The Search in Transformation Domain

P kxk

Q

P

T()P

(Q,P)

Page 6: Real Time Pattern Detection

-0.2-0.15

-0.1-0.05

00.05

0.10.15

0.2 -0.2

-0.1

0

0.1

0.2

-0.2

-0.1

0

0.1

0.2

rotation of 2D signal projected into its 3 highest eigen-vectors

-0.2-0.15

-0.1-0.05

00.05

0.10.15

-0.2

-0.1

0

0.1

0.2

0.3

-0.2

-0.15

-0.1

-0.05

0

0.05

0.1

0.15

0.2

A rotation manifold of a pattern drawn in “pattern-space”The manifold was projected into its three most significant components.

Page 7: Real Time Pattern Detection

Suggested ApproachReduce complexity of search using 2 complementaryprocesses:1. Reduce search in Spatial Domain.2. Reduce search in Transformation Domain.

Both processes are based on a Rejection Scheme.

Page 8: Real Time Pattern Detection

Efficient Search in the Spatial Domain

• • •

Page 9: Real Time Pattern Detection

• • •

Nyx

E yxPvyuxIvud,

2,,,

Ntyx

E tyxPwtvyuxItvud,,

2,,,,,,

The Euclidean Distance

Page 10: Real Time Pattern Detection

Complexity (2D case)

Average # Operations per

PixelSpace Integer

Arithm.

Run Time for 1Kx1K Image32x32 pattern PIII, 1.8 Ghz

Naive+: 2k2

*: k2n2 Yes 5.14 seconds

Fourier+: 36 log n

*: 24 log n n2 No 4.3 seconds

Page 11: Real Time Pattern Detection

• Representing an image window and the pattern as vectors in Rkxk:

Norm Distance in Sub-space

dE(p,q)= ||p-q||2=|| - ||2

dE(p,q) |u|-2 dE(pTu, qTu)

u p

q

• If p and q were projected onto a vector u, it follows from the Cauchy-Schwarz Inequality:

Page 12: Real Time Pattern Detection

• If q and p were projected onto a set of vectors [U]:

Distance Measure in Sub-space (Cont.)

r

kk

Tk

TE

kE uqupd

Sqpd

12 ,1,

u1

p

qu2

It can be shown that:

Page 13: Real Time Pattern Detection

Two necessary requirements:1. Choose projecting kernels [U] having high

probability to be parallel to the vector p-q.2. Choose projecting kernels that are fast to apply.

How can we Expedite the Distance Calculations?

Natural Images

u1

Page 14: Real Time Pattern Detection

Following the above requirement we use the kxk

Walsh-Hadamard basis vectors

• Each window in a natural image is closely spanned by the first few basis vectors.

• Can be applied very fast in a recursive manner.

Projecting Kernels: Walsh-Hadamard

Page 15: Real Time Pattern Detection

The Walsh-Hadamard Kernels:

Page 16: Real Time Pattern Detection

Walsh-Hadamard v.s. Standard Basis:

The lower bound for distance value in %v.s. number of Walsh-Hadamard projections,Averaged over 100 pattern-image pairs of size 256x256 .

The lower bound for distance value in %v.s. number of standard basis projections,Averaged over 100 pattern-image pairs of size 256x256 .

Page 17: Real Time Pattern Detection

The Walsh-Hadamard Tree (1D case)

+-+ -

- +

+

+ ++ -

+ + + ++ + - -+ - + - + - - ++ - +- + - +-

+ - + - - + - ++ - + - + - + - + + + + + + + ++ + + + - - - -+ + - - + + - - + + - - - - + ++ - - + + - - ++ - - + - + + -

WH-tree for 1D pattern of size 8

Page 18: Real Time Pattern Detection

The Walsh-Hadamard Tree - Example

- +

+

+ - + +

+ - +-

+ + + ++ + - -+ - + - + - - +

15 6 10 8 8 5 10 1

21 16 18 16 13 15 11

39 32 31 31 24

9 -4 2 0 3 -5 9

11 -4 5 -5 12

3 0 5 1 2 7 -4 -1 5 6

Page 19: Real Time Pattern Detection

- +

+

+ - + +

+ - +-

+ + + ++ + - -+ - + - + - - +

• Descending from a node to its child requires one addition operation per pixel.

• A projection of the entire image onto one basis vector is performed in a top-down traversal.

• A projection of a particular window in the image onto one basis vector is performed in a bottom-up traversal.

Properties:

• All operations are performed in integers.

Page 20: Real Time Pattern Detection

• Projecting all windows in the image onto a basis vector requires log k additions per pixel.

• Projecting all windows in the image onto l<k basis vectors requires m additions per pixel, where m is the number of nodes preceding the l leaf.

• Projecting all windows in the image onto k basis vectors requires 2k additions per pixel.

• Projecting a single window onto a single

basis vector requires k-1 additions.

Complexity (1D):

- ++

+ - + +

+ - +-

+ + + ++ + - -+ - + - + - - +

Page 21: Real Time Pattern Detection

• For the 2D case, the projection is performed in a similar manner where the tree depth is 2log k

• The complexity is calculated accordingly.

Walsh-Hadamard Tree (2D):

+

+ - + +

+ + + +

+ + - -

+ - + -

+ - - +

+ - + +

+ +

+-

+-

+ +

Construction tree for 2x2 basis

Page 22: Real Time Pattern Detection

– Iteratively apply Walsh-Hadamard vectors to each window wi in the image.

– At each iteration and for each wi calculate a lower-

bound Lbi for |p-wi|2 .

– If the lower-bound Lbi is greater than a pre-defined

threshold, reject the window wi and ignore it in further projections.

Pattern Matching algorithm

Page 23: Real Time Pattern Detection

Pattern Matching algorithm - Complexity

All windows are projected onto the first kernel :

2logk ops/pixel

Only a few windows are further projected using ~2k operations per active window :

ops/pixel

Total : 2logk + ops/pixel

Page 24: Real Time Pattern Detection

Initial Image: 65536 candidates

Sought Pattern

Example:

Page 25: Real Time Pattern Detection

After the 1st projection: 563 candidates

Page 26: Real Time Pattern Detection

After the 2nd projection: 16 candidates

Page 27: Real Time Pattern Detection

After the 3rd projection: 1 candidate

Page 28: Real Time Pattern Detection

Percentage of windows remaining following each projection,averaged over 100 pattern-image pairs.

Image size = 256x256, pattern size = 16x16.

Page 29: Real Time Pattern Detection

Accumulated number of additions after each projectionaveraged over 100 pattern-image pairs.Image size = 256x256, pattern size = 16x16.

Average Number of operations per pixel: 8.0154

Page 30: Real Time Pattern Detection

Example with NoiseOriginal Noise Level = 40 Detected patterns.

Number of projections required to find all patterns, as a function of noise level. (Threshold is set to minimum).

Page 31: Real Time Pattern Detection

Percentage of windows remaining following each projection,

at various noise levels.

Image size = 256x256, pattern size = 16x16.

0 50 100 150 200 250-5

0

5

10

15

20

25

30

35

Projection #

% W

indo

ws

Rem

aini

ng

0 5 10 15

0

1

2

3

4

Page 32: Real Time Pattern Detection

DC-invariant Pattern Matching

OriginalIllumination

gradient added Detected patterns.

Five projections are required to find all 10 patterns (Threshold is set to minimum).

Page 33: Real Time Pattern Detection

Complexity (2D case)

Average # Operations per

PixelSpace Integer

Arithm.

Run Time for 1Kx1K Image32x32 pattern PIII, 1.8 Ghz

Naive+: 2k2

*: k2n2 Yes 4.86 seconds

Fourier+: 36 log n

*: 24 log nn2 No 3.5 seconds

New +: 2 log k + n2 log k Yes 78 msec

Page 34: Real Time Pattern Detection

• Walsh-Hadamard per window can be applied very fast.• Projections are performed with additions/subtractions

only (no multiplications).• Integer operations.• Fast rejection of windows.• Possible to perform pattern matching at video rate. • DC invariant pattern matching.

• Extensions: – Other norms.– Multi size pattern matching.

Advantages:

Page 35: Real Time Pattern Detection

• 2n2 log k memory size.• Pattern size must be 2m .

• Limited to normed distance metrics.

Limitations:

Page 36: Real Time Pattern Detection

Efficient Search in the Transformation Domain

Page 37: Real Time Pattern Detection

Transformation Manifold

T()P is a transformation T() applied to pattern P.

T()P for all forms an orbit in kxk

T()P

T(0)P

T(2)P

T(1)P

A pattern P can be represented as a point in kxk

P

Page 38: Real Time Pattern Detection

Fast Search in Group Orbit• Assume d(Q,P) is a distance metric.

• We would like to find

Q

P

T()P(Q,P)

(Q,P)=min d(Q, T()P)

Page 39: Real Time Pattern Detection

Fast Search in Group Orbit (Cont.)• In the general case (Q,P) is not a metric.

Q

P

R

• Observation: if d(Q,P)= d(T()Q, T()P)

(Q,P) is a metric

Page 40: Real Time Pattern Detection

Fast Search in Group Orbit (Cont.)The metric property of (Q,P) implies triangular inequality on the distances.

Q

P

S

Page 41: Real Time Pattern Detection

Orbit Decomposition• In practice T() is sampled into T (i)=T(i) , i=1,2,…

QP(Q,P)

T(i)P

P’

• We can divide T(i)P into two sub-orbits:

T2(i)P and T2(i)P’ where P’= T(1) P

2

T2(i)P

Page 42: Real Time Pattern Detection

Orbit Decomposition (Cont.)

T2(i)P T2(i)P’

PQPQMinPQ ,,,, 22

Q

T(i)P

(Q,P)

P

P’

2(Q,P) 2(Q,P’)

P

P’

Page 43: Real Time Pattern Detection

Orbit Decomposition (Cont.)

T2(i)P T2(i)P’

Q

2(Q,P) 2(Q,P’)

P

P’

Since 2 is a metric and 2(P,P’) can be calculated in advancewe may save calculations using the triangle inequality constraint.

2 (P,P’)

Page 44: Real Time Pattern Detection

• The sub-group subdivision can be applied recursively.

Orbit Decomposition (Cont.)

Page 45: Real Time Pattern Detection

Fast Search - Example

Page 46: Real Time Pattern Detection
Page 47: Real Time Pattern Detection
Page 48: Real Time Pattern Detection
Page 49: Real Time Pattern Detection
Page 50: Real Time Pattern Detection
Page 51: Real Time Pattern Detection
Page 52: Real Time Pattern Detection
Page 53: Real Time Pattern Detection

Fast Search in Group Orbit: Conclusions

• Observation 1: Orbit distance is a metric when the point distance

is transformation invariant.

• Observation 2: Fast search in orbit distance space can be applied

using recursive orbit decomposition.

• Distant patterns are rejected fast.

• Important: Can be applied to any metric distance d(Q,P).

Page 54: Real Time Pattern Detection

Pattern Detection using 2 complementary processes:1. Reduce search in Transformation Domain.2. Reduce search in Spatial Domain.

Processes are based on rejection schemes, and are restricted to a specific domain.

The two processes can be combined into a single, highly efficient, search process.

Conclusion

--- END ---