Ask Your Question

Revision history [back]

Why is ShapeContextDistanceExtractor::computeDistance not commutative?

Hey,

I'm trying to use ShapeContextDistanceExtractor to find distances between contours, and for some reason changing the order of arguments in computeDistance method leads to different results. For example, here are two contours

Contour #1
0 14
2 12
4 10
6 8
8 7
10 6
13 5
15 4
18 3
20 2
22 1
24 1
27 0
29 0
31 0
33 0
36 0
38 0
41 0
43 1
45 1
47 2
49 3
51 4
55 5
57 6
59 7
61 8
63 9
65 11
68 13
66 13
64 14
62 15
60 15
58 16
55 17
53 18
50 18
48 19
46 19
44 20
41 20
39 20
37 21
35 21
32 21
30 22
27 22
25 22
23 22
21 22
19 22
16 21
13 19
11 18
9 18
7 17
5 16
3 15

Contour #2
0 15
2 13
5 10
7 9
10 7
12 6
15 4
17 3
20 2
22 1
25 1
27 0
30 0
32 0
35 0
37 0
40 0
42 1
45 2
47 2
50 4
52 5
55 6
57 7
60 10
62 11
65 13
67 15
69 18
69 20
69 23
67 24
65 25
62 26
60 27
57 29
55 29
52 30
50 31
47 32
45 33
42 33
40 34
37 34
35 34
32 34
30 34
27 34
25 34
22 33
20 32
17 31
15 31
12 29
10 28
7 26
5 24
2 22
0 20
0 17

Depending on the order of arguments computeDistance returns either 0.32094 or 0.26297. Why is this method not commutative? And does order of points inside contours affect the resulting distance?