1 An Efficiently Computable Metric for Comparing Polygonal Shapes Esther M. Arkin, L. Paul Chew, Daniel P. Huttenlocher, Klara Kedem, Joseph S.B. Mitchell Liron Katav, Ilya Mirsky A B C D
Outline 1. Introduction 2. Definitions 3. Representation of Polygons 4. Distance Function 5. The Algorithm 6. Examples 7. References 27/12/20102
Introduction Model-based recognition is concerned with comparing a shape A, which is stored as a model for some particular object, with a shape B, which is found to exist in an image. If A and B are close to be the same object, then the vision system should report a match and return a measure of how good the match is. 27/12/20103 A model of a circle
Introduction (cont’d) To be useful this measure should satisfy several properties: It should be a metric. It should be invariant under translation, rotation, scaling, in other words it should measure shape alone. It should be reasonably easy to compute. It should match our intuition (i.e., answers should be similar to those that a person might give). It should be insensitive to small perturbations. 27/12/20104
Introduction (cont’d) 27/12/20105
Outline 1. Introduction 2. Definitions 3. Representation of Polygons 4. Distance Function 5. The Algorithm 6. Examples 7. References 27/12/20106
Definitions 27/12/20107
Outline 1. Introduction 2. Definitions 3. Representation of Polygons 4. Distance Function 5. The Algorithm 6. Examples 7. References 27/12/20108
Representation of Polygons 27/12/20109 O V4V4 V3V3 V2V2 V1V1 x axis O
Representation of Polygons (cont’d) 27/12/ s O O V3V3 V2V2 x axis V1V1 V1V1 V2V2 V3V3
Representation of Polygons (cont’d) 27/12/ The turning function The turning function accumulates turns. Notice that it increases with left-hand turns, and decreases with right-hand turns. s 1 a b c d e f 0 x axis a b c d e f
Representation of Polygons (cont’d) 27/12/201012
Representation of Polygons (cont’d) 27/12/201013
Representation of Polygons (cont’d) 27/12/201014
Representation of Polygons (cont’d) 27/12/ Rotation only affects the first angle v x axis s 1 0 s 1 0
Representation of Polygons (cont’d) Change of the reference point- Suppose the new reference point is at position s = t in the polygon before the change. In the new graph of the turning function, the actual angles and lengths remain the same, only the graph is shifted horizontally by t. 27/12/ s O 0 V3V3 V2V2 x axis V1V1
Outline 1. Introduction 2. Definitions 3. Representation of Polygons 4. Distance Function 5. The Algorithm 6. Examples 7. References 27/12/201017
Distance Function 27/12/201018
Distance Function (cont’d) 27/12/ Minimization Problem
Distance Function (cont’d) Observations: It’s a metric. It’s convex function- notice that d 2 (A, B) 2 is a sum of quadratic terms and is therefore a convex function. In order to compute the distance, we must minimize over all t's and θ 's. Notice also that a minimum for d 2 (A, B) is a minimum for d 2 (A, B) 2. Since the latter function is convex, it admits a single minimum. This means that for a given value of t, the optimum value of θ depends on this t only and is unique. Thus, we have but a single- variable minimization problem. 27/12/201020
Distance Function (cont’d) 27/12/201021
Distance Function (cont’d) Suppose we know this θ *(t). Then: 27/12/201022
Distance Function (cont’d) Now it remains to show how to compute | Θ A (s+t) - Θ B (s)| for each t. Note that Θ A (s+t) is a copy of Θ A (s) read from t to t+1. Since Θ A (s) can be defined over the whole real line (not just on [0, 1]), simply by repeating the pattern of the turning function infinitely to the left and to the right, with the pattern to the left increasing in height by 2 π for each unit and the pattern to the right decreasing in height by 2 π for each unit. 27/12/201023
Distance Function (cont’d) 27/12/ s 1 0 2
Distance Function (cont’d) Consider discontinuities of Θ A (s+t) and Θ B (s) in [0,1]. They make the rectangular strips made by the functions and the dashed lines. If polygon A has n vertices and polygon B has m vertices, then the number of "strips" made in this way is m + n - 1 (each vertex contributes a "step" of the turning angle function). 27/12/201025
Distance Function (cont’d) The portion between Θ A (s+t) and Θ B (s) over the interval ds forms a rectangular strip. In order to evaluate | Θ A (s+t) - Θ B (s)| over the interval ds, | Θ A (s+t) - Θ B (s)| is computed as the height of the rectangular strip and ds is computed as the width of this strip. For a given t, we may now evaluate d 2 (A, B), since we know how to compute | Θ A (s+t) - Θ B (s)|, ds, and since θ *(t) is computed from t. Finally, we take the minimum over all t's. Suppose the minimum distance occurs for some t*. Then the best match between the two turning functions Θ B (s) and Θ A (s) occurs when Θ A (s) is shifted horizontally by t* and vertically by θ *(t*). 27/12/201026
Observations: 27/12/ During the shifting operation the breakpoints of Θ A (s+t) collide with the breakpoints of Θ B (s ). We define a critical event as a value of t where such colliding occurs. There are m*n critical events. The distance function achieves its minimum at one of the critical events. So, we get m*n possible values for t. This is the number of ways in which a discontinuity of Θ A (s) can be aligned with a discontinuity of Θ B (s)
Outline 1. Introduction 2. Definitions 3. Representation of Polygons 4. Distance Function 5. The Algorithm 6. Examples 7. References 27/12/201028
Algorithm Description 27/12/ For each of the mn critical events t for Θ A (s) and Θ B (s): 1.1. Find the function Θ A (s+t) 1.2. For each of the m+n-1 rectangular strips made by Θ A (s+t) and Θ B (s): Compute the height | Θ A (s+t) - Θ B (s)|, width ds, and θ *(t) Get a final answer for the distance for this value of t 1.3. Update the value of the current minimal distance 2. Return the minimum distance
Time Complexity 27/12/ Calculation of the function Θ A (s+t) for a given t takes constant time (using the trick with extending Θ A (s) to the whole real line). So does computing the height | Θ A (s+t) - Θ B (s)|, width ds, and θ *(t) within one rectangular strip, and also the updates of the distance take constant time. we conclude that the algorithm runs in O(nm(n+m)) time. The O(nm(n+m)) complexity could be improved to O(nmlog(nm)) by using more complex algorithm.
Outline 1. Introduction 2. Definitions 3. Representation of Polygons 4. Distance Function 5. The Algorithm 6. Examples 7. References 27/12/201031
Examples 27/12/201032
Examples 27/12/ Distance : Horizontal shift: Vertical shift:-1.928
Examples 27/12/201034
Examples 27/12/ Distance : Horizontal shift: Vertical shift:-6.174
Examples 27/12/ Distance : Horizontal shift: Vertical shift:-2.03
Examples 27/12/ Resemblance to square and triangle, in decreasing order Distance from original shape
Outline 1. Introduction 2. Definitions 3. Representation of Polygons 4. Distance Function 5. The Algorithm 6. Examples 7. References 27/12/201038
References 27/12/ Esther M. Arkin, L. Paul Chew, Daniel P. Huttenlocher, Klara Kedem, Joseph S.B. Mitchell; “An Efficiently Computable Metric for Comparing Polygonal Shapes”,