Title: SCALED PATTERN MATCHING
1SCALED PATTERN MATCHING
- A.Amir Bar-Ilan Univ. Georgia Tech
- A.Butman Holon College
- M.Lewenstein Bar-Ilan Univ.
- E.Porat Bar-Ilan Univ.
2SEARCHING FOR TEMPLATES IN AERIAL PHOTOGRAPHS
INPUT
TASK Search for all locations where the
template appears in the image.
3 Theoretically, need to consider
- Noise
- Occlusion
- Scaling (size)
- Rotation (orientation)
We are interested in asymptotically efficient
algorithms in pixel space.
4MODEL
- Low Level (pixel level) avoid costly
preprocessing - Asymptotically efficient solutions.
- Serial, exact algorithms.
5TYPES OF APPROXIMATIONS
Local Errors Level of detail Occlusion Nois
e
6TYPES OF APPROXIMATIONS
Orientation
7EVEN WITHOUT ERRORS AND ROTATIONS
- DIGITIZING NEWSPAPER STORIES
- IDEA Keep dictionary of fonts
- Search for appearances in all size.
8PROBLEM
- INHERENTLY INEXACT
- What if appearance is 1½ times bigger ?
- What is ½ a pixel ?
SOLUTIONS UNTIL NOW NATURAL SCALES Consider
only discrete scales
9- How does one model for
- real scales?
10Step 1 Define grid pixel centers.
Example Unit pixel array for a 7?7 array.
11Step 2 Define scaling. Example 3?3 array.
Scaled To 1?
12(No Transcript)
13(No Transcript)
14(No Transcript)
15(No Transcript)
16Scaled To 1?
17Remark
- We only scale up
- Reasons
- Avoid conceptual problems of loss of resolution.
- From far enough away everything looks the same.
18Let P be a m?m pattern and T an n?n text.
How many different scaled patterns of P are
there?
19In fact, can there be two different scaled
patterns of P of size k?k?
20Example
55
214 x 1.1 4.4
Scaled by 1.1 to 6x6
224 x 1.125 4.5
Scaled by 1.125 to 6x6
233 x 1.17 3.51
Scaled by 1.17 to 6x6
242 x 1.25 2.5
Scaled by 1.25 to 6x6
25Let P be a m?m pattern and T an n?n text.
How many different scaled patterns of P are
there?
26Claim
- There are nm different scaled patterns
representing all the occurrences of P.
27Proof
Each one has at most m possible matrices
representing it
m?m, (m1)?(m1), , n?n
n-m different possible sizes
28Proof
Each one has at most m possible matrices
representing it
Why?
29Distance 1
30Pattern P scaled to size kk,
31(No Transcript)
32Therefore
- There are nm different scaled patterns
representing all the occurrences of P.
33Algorithm outline for 2-D scaled matching
34Straightforward Idea
- Construct dictionary of O(nm) possible scaled
occurrences of P. - Use 2-dimensional dictionary matching algorithm
to scan the text in linear time and find all
occurrences.
35Space and Time Analysis
Each one has at most m possible matrices
representing it
m?m, (m1)?(m1), , n?n
Dictionary size O(n3m)
36Solution
- Our idea is to keep the dictionary in compressed
form. - The compression we use is run-length of the rows.
37Run-length
aabcccbb
a2b1c3b2
38The compressed dictionary
C C B B B A A
C C B B B A A
F F E E E D D
F F E E E D D
F F E E E D D
I I H H H G G
I I H H H G G
C B A
F E D
I H G
Scaled To 2?
39C C B B B A A
C C B B B A A
F F E E E D D
F F E E E D D
F F E E E D D
I I H H H G G
I I H H H G G
2 C2 B3 A2
3 F2 E3 D2
2 I2 H3 G2
Compressed form
402 C2 B3 A2
3 F2 E3 D2
2 I2 H3 G2
Size of Array mxm
of diff. scaled patterns (n-m) x m
Dictionary size O(nm3)
41The Idea behind the text searching
- For every text location i,j, we assume that
there is a pattern scaled occurrence beginning at
that location. - Subsequently, we establish the number of times
this row repeats in the text. - This allows us to an appropriately scaled pattern
row from the dictionary.
42Example for text searching
43c150
b
a10
1
aaaaaaaaaa
44Look in the text location 1,10
45(No Transcript)
46c150
b
a10
1
47c150
b
a10
1
aaaaaaaaaab
48c150
b
a10
1
Look in the text location 1,10
aaaaaaaaaabccccccccccccccc
49(No Transcript)
50A scale range of 1,1¼)
51Last symbol may repeat in the text more time
than the scaled pattern need.
52What about the number of times the first subrow
repeats?
53The range of 1,1¼) is valid since
?102?1¼?128lt132.
54Look in the text location 1,9
55(No Transcript)
56A scale range of 1¼,1¾)
57Too large, it requires the c to repeat 175 times.
1¾
58(No Transcript)
59(No Transcript)
60The maximum scale valid for both horizontal and
vertical scales produces the pattern whose first
row is a2bc129 and which repeats 132 times.
61(No Transcript)
62OPEN PROBLEM
- Give algorithm linear in run-length compressed
text and pattern.
63END