630 likes | 744 Views
S C A L E D PATTERN MATCHING. A.Amir Bar-Ilan Univ. & Georgia Tech A.Butman Holon College M.Lewenstein Bar-Ilan Univ. E.Porat Bar-Ilan Univ. . TEMPLATE. AERIAL PHOTO. SEARCHING FOR TEMPLATES IN AERIAL PHOTOGRAPHS. INPUT. TASK: Search for all locations where the template
E N D
SCALED PATTERN MATCHING A.Amir Bar-Ilan Univ. & Georgia Tech A.Butman Holon College M.Lewenstein Bar-Ilan Univ. E.Porat Bar-Ilan Univ.
TEMPLATE AERIAL PHOTO SEARCHING FOR TEMPLATES IN AERIAL PHOTOGRAPHS INPUT TASK: Search for all locations where the template appears in the image.
local errors Theoretically, need to consider: • Noise • Occlusion • Scaling (size) • Rotation (orientation) We are interested in asymptotically efficient algorithms in pixel space.
MODEL • Low Level (pixel level) avoid costly preprocessing • Asymptotically efficient solutions. • Serial, exact algorithms.
Results: mismatches AL-88 edit distance, k errors, rectangular patterns edit distance, k errors, half-rectangular patterns AF-95 TYPES OF APPROXIMATIONS Local Errors: Level of detail Occlusion Noise
Results: FU-98 ACL-98 TYPES OF APPROXIMATIONS Orientation
A B C EVEN WITHOUT ERRORS AND ROTATIONS … DIGITIZING NEWSPAPER STORIES IDEA: Keep dictionary of fonts Search for appearances in all size.
1 2 3 4 5 PROBLEM INHERENTLY INEXACT What if appearance is 1½ times bigger ? What is ½ a pixel ? SOLUTIONS UNTIL NOW: NATURAL SCALES Consider only discrete scales
How does one model for real scales?
1 2 3 4 5 6 7 T[1,1] T[1,2] T[1,3] 1 T[2,1] T[2,2] T[2,3] 2 T[3,1] T[3,2] T[3,3] 3 4 T[5,4] 5 6 T[7,7] 7 Step 1:Define grid & pixel centers. Example:Unit pixel array for a 77 array.
Step 2:Define scaling. Example:33 array. Scaled To 1⅓
Scaled To 1⅓
Remark: • We only scale “up” Reasons: • Avoid conceptual problems of loss of resolution. • From “far enough” away everything looks the same.
Let P be a mm pattern and T an nn text. How many different scaled patterns of P are there?
In fact, can there be two different scaled patterns of P of size kk?
Example: 5×5
4 x 1.1 = 4.4 Scaled by 1.1 to 6x6
4 x 1.125 = 4.5 Scaled by 1.125 to 6x6
3 x 1.17 = 3.51 Scaled by 1.17 to 6x6
2 x 1.25 = 2.5 Scaled by 1.25 to 6x6
Let P be a mm pattern and T an nn text. How many different scaled patterns of P are there?
Claim There are ≤ nm different scaled patterns representing all the occurrences of P.
… Proof: Each one has at most m possible matrices representing it mm, (m+1)(m+1), … , nn n-m different possible sizes
Proof: Each one has at most m possible matrices representing it Why?
… … … … … … … … … (k-½)×(k -½) (k+½)×(k +½) … … … Pattern P scaled to size k×k,
Therefore There are ≤ nm different scaled patterns representing all the occurrences of P.
Algorithm outline for 2-D scaled matching
Straightforward 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.
… Space and Time Analysis Each one has at most m possible matrices representing it mm, (m+1)(m+1), … , nn Dictionary size O(n3m)
Solution • Our idea is to keep the dictionary in compressed form. • The compression we use is run-length of the rows.
Run-length aabcccbb a2b1c3b2
The compressed dictionary Scaled To 2⅓
# of repetitions of row Compressed form
# of repetitions of row Size of Array: mxm # of diff. scaled patterns: (n-m) x m Dictionary size: O(nm3)
The 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.
T: 1 a10 b c150 … a10 b c150 … 2 . . . . . . . . . . . . . . . P: 1 a b c100 a b c100 2 a10 b c150 … 132 . . . . . . . . . . . . b10 c d150 … 133 . . . . . . . . . . . . . . . 102 a b c100 Example for text searching
1 a10 b c150 … aaaaaaaaaa
T: 1 a10 b c150 … a10 b c150 … 2 . . . . . . . . . . . . . . . P: 1 a b c100 a b c100 2 a10 b c150 … 132 . . . . . . . . . . . . b10 c d150 … 133 . . . . . . . . . . . . . . . 102 a b c100 Look in the text location [1,10]
T: 1 a10 b c150 … a10 b c150 … 2 . . . . . . . . . . . . . . . P: 1 a b c100 a b c100 2 a10 b c150 … 132 . . . . . . . . . . . . b10 c d150 … 133 . . . . . . . . . . . . . . . 102 a b c100
1 a10 b c150 …
1 a10 b c150 … aaaaaaaaaab
1 a10 b c150 … Look in the text location [1,10] aaaaaaaaaabccccccccccccccc…
22 2½2½ T: 1 a10 b c150 … a10 b c150 … 2 . . . . . . . . . . . . . . . P: 1 a b c100 a b c100 2 a10 b c150 … 132 . . . . . . . . . . . . b10 c d150 … 133 . . . . . . . . . . . . . . . 102 a b c100
T: 1 a10 b c150 … a10 b c150 … 2 . . . . . . . . . . . . . . . P: 1 a b c100 a b c100 2 a10 b c150 … 132 . . . . . . . . . . . . b10 c d150 … 133 . . . . . . . . . . . . . . . 102 a b c100 A scale range of [1,1¼)