Approximate decision algorithms for approximate congruence

Approximate decision algorithms for approximate congruence

Information Processing North-Holland Letters 10 August 43 (1992) 29-34 1992 Approximate decision algorithms for approximate congruence Stefan Sc...

519KB Sizes 11 Downloads 100 Views

Information Processing North-Holland

Letters

10 August

43 (1992) 29-34

1992

Approximate decision algorithms for approximate congruence Stefan

Schirra

*

Max-Planck-lnstitut fiir Informatik, Im Stadtwald, W-6600 Saarbriicken, Germany Communicated by T. Lengauer Received 29 August 1991 Revised 20 April 1992 KeywordA: Computational

geometry,

computer

vision, point matching

1 < i < n. We say that I and I enable approximate congruence for A and B.

1. Introduction Two sets A and B of points in the plane are called congruent if there is an isometry which maps the points in A onto the points in B, where a map I: LQ2+ R* is called an isometry if dist,(a, b) = dist,(Z(a), I(b)) for all points a and 6. Here dist, stands for Euclidian metric. Although there are several optimal O(n log n) algorithms [1,2] for testing congruence, this is difficult in practice. Clearly, algorithms for testing congruence are highly sensitive to inexact computations and inaccuracies in the input data. Therefore Alt et al. [l] considered approximate congruence. Definition 1 (Alt et al.>. Let A = (a,, . , . , a,) and 6,) be two sets of points in the plane B={b,,..., and let F be a nonnegative real number. The point sets A and B are called approximately congruent with tolerance e (or .5-congruent > is an isometric mapping I and a bijective labeling /:A + B exist such that didI(a /(a,)) G E for all i,

Correspondence to: S. Schirra, Max-Plan&Institut fir Informatik, AG 1: Datenstrukturen und Algorithmen, Im Stadtwald, W-6600 Saarbriicken, Germany. * This work was supported by the DFG Schwerpunktprogramm “Datenstrukturen und effiziente Algorithmen” Grant Me 620/6. 0020-0190/92/$05.00

0 1992 - Elsevier

Science

Publishers

Note that the approximate congruence as defined above depends on the chosen metric. We consider the following decision problem: Given two sets A and B of points in the plane and a tolerance value F, decide whether A and B are s-congruent with respect to Euclidian metric. Ah et al. [l] gave an algorithm for this decision problem and algorithms for some restricted decision problems where the approximate congruence must be enabled by special isometries e.g. translations, rotations with a fixed center, etc. They also considered different metrics. The decision algorithm of Alt et al. for the general case with Euclidian metric has running time O(nX> (in contrast to several optimal O(n log n) algorithms [1,2] for testing exact congruence). In the case of exact congruence the isometry fixes the correspondence between the points. In the approximate case, however, the correspondence between the points, i.e. the labeling, has to be found by the algorithm. Therefore the problem is easier if a labeling is fixed in advance: Alt et al. [l] and Iwanowski [5] gave O(n log n) time algorithms for some restricted decision problems and Imai et al. [4] presented algorithms for the general case with time complexity 0(n3 log n) for

B.V. All rights reserved

29

Volume

43, Number

I

INFORMATION

PROCESSING

Euclidian metric and O(n) for maximum metric (Imai et al. compute the smallest tolerance value permitting approximate congruence for the given point sets). We consider here the case that no labeling is given and use Euclidian metric. The algorithms presented in this paper for testing approximate congruence with tolerance e of two sets of points are called approximate, since they are not complete in the sense that they always take a decision, but they are very near to decision algorithms. For sets A and B there is a small set of tolerance values where approximate decision algorithms report that they cannot solve the decision problem. However, if a decision has been taken, the answer is correct. Since the running times of known algorithms for testing approximate congruence are far from being practical, efficient approximate decision algorithms are interesting. Note that we use the term approximate in two senses, firstly for algorithms near to decision algorithms, and secondly for a property of point sets near to congruence. The basic idea of approximate decision algorithms for approximate congruence is known from daily life. If one compares distances (e.g. between cities on a map) most of the time it is obvious which of two distances is smaller. A tape-measure is necessary only if the distances are nearly equal. Almost the same applies to approximate congruence. It is not necessary to have a complicated algorithm that solves every problem instance. There are simpler and faster strategies that work correctly if the test value E is evidently large enough to permit approximate congruence or evidently too small. More precisely, we call an algorithm an (a, p>-approximate decision algorithm for approximate congruence if it solves the decision problem for all E outside the interval

LETTERS

30

1992

taken. Hence an (a, /3)-approximate algorithm always terminates and works reliably, i.e. all YES and NO answers are correct. In the next section we derive a (+&,,,,(A, B), E,,,,( A, B ))-approximate algorithm for approximate congruence by translations with running time O(n*.‘) and a (+E,,,~(A, B) E~~((A, B))-approximate algorithm with running time O(n4) for the general case. In Section 3 an additional input parameter y < F is used as tradeoff between running time and size of the indecision interval. We give a (y, -y)-approximate algorithm with running time 0((s/yj2n4> for the general case. The comparable ((0, O&approximate) algorithm of Alt et al. [l] has running time O(nX). Furthermore we give a (y, y)-approximate algorithm with running time O((~/y)~n~-’ > for testing approximate congruence by translation. Here the comparable algorithm of Alt et al. has running time O(n’). Recently, Heffernan has given a (y, yj-approximate algorithm with running time O((~/y>‘n”> for approximate congruence by translations [3]. Section 4 offers some concluding remarks.

2. First approximate

decision

algorithms

First of all we derive a (+E,~~(A, B), E,,~(A, B))-approximate algorithm for testing E-congruence by translation of two point sets A = {a,, . , a,} and B = {6,, . . . , b,,}. Then we give a algorithm (&JA, B), Fop*(A, B))-approximate for the general case. Both algorithms are based on the fact that an isometry which enables approximate congruence maps the centroid cA near to the centroid cg of B. Lemma 2. Elsely isometry I which enables e-congruence maps cA into the ball with radius E and center cB. Proof. enable

where E<)~,(A, B) is the smallest tolerance value permitting approximate congruence for A and B by the allowed isometries. Furthermore we require that an (a, P&approximate algorithm reports DON’T KNOW if a decision cannot be

10 August

dist(I(c,),

Let 1 be a labeling such E-congruence. We have cB) =dist [ I ($lKa;), G t xdist(Z(a;),

that

I and

+XlCa;)) /(a,))

GE. 0

1

Volume

43, Number

1

INFORMATION

PROCESSING

(1) if G(T ( ,Ln. P, A, B) has a perfect matching then ieturn YES ii; (2) if G(T, ,c,l, 2~. A, B) has no perfect matching then return NO fi; (3) return DON’T KNOW: Fig. 1.

For arbitrary points d and e in the plane T/r be the translation that maps d onto e.

let

Lemma 3. Let T be a translation and 1 a labeling which enable e-congruence for A and B. T,,?,,< enables approximate congruence for A und B with tolerance E + dist(T(c,), c,). Proof. T is the composition of T,. in and translation which maps cB onto T(cj\. 0

the

For isometry

I let G(1, E, A, B) be the graph where U= (U ,,..., u,) and V= the points in A and B resp. (L ,, . . . , lsn} represent and E’ = {{u,, t’k} I I maps a, into the E-ball with center 6,). Lemma 3 leads to the approximate decision algorithm in Fig. 1 for testing approximate congruence by translation.

(UU

V,

E)

10 August

1992

Proof. A labeling which together with T.,<, enables s-congruence corresponds to a perfect matching of the bipartite graph G(TCA1,.,,, E, A, B). Hence T,.,I,.Benables F-congruence iff G(q.,4C.II, &, A, B) has a perfect matching. So all YES answers are reliable. If there is a translation and a labeling 1 which enable E-congruence, then q. (‘,I and 1 enable 2&-congruence. Hence, if A G?T, ,cn> 2.5, A, B) has no perfect matching, and B are not e-congruent by a translation. For the time analysis note first that the centroids of A and B, and TC,C,$A) can be computed in time O(n). G(TC.A’.,j, E; A, B) and G(TC,(,, 2&, A, B) can be constructed in time 0(n2>. Testing for a perfect matching can be done by computing a maximum matching in time O(n’.‘I [7]. For F < ~E,,~~(A, B), no translation enables 2E-congruence. Hence the answer is NO in this case. On the other hand, the output has to be YES for E > 2e,,],( A, B) by Lemma 3. Therefore the indecision interval is [+F~,,~,(A, B), ~E,,,,,(A, B)). Figure 2 shows the dependence of the algorithm on E and E,~,,(A, B). 0 For the general case the following basic observation 111 is helpful. It is sufficient to have a decision algorithm for approximate congruence by a composition of a translation and a rotation, since every other isometry is a composition of a reflection at a line that can be chosen arbitrarily,

Theorem 4. The algorithm in Fig. 1 is a (~E,,,~(A, algorithm for e-conB), Eo,,t( A, B))-approximate gruence by translation with time complexity O( n ‘.’ 1. T =ACB does not enable r-congruence

LETTERS

T CACBmay

T elcB enables

enable c-congruence

r-congruence

/ E

0

r

r

NO or DON’T

NO

r 0

$~opt(A,

YES or DON’T KNOW

KNOW

YES

r B)

%p&%

r k&4,

B)

Fig. 2. Output

in relation

> B)



to F,,,,, (A. B)

31

Volume

43, Number

1

INFORMATION

PROCESSING

a translation and a rotation. Such a decision algorithm can then be applied first to A and B and then to A and B reflected at the x-axis. If the output is NO in both tests, then A and B are not E-congruent. If the output is YES in at least one test, then A and B are &-congruent. It is not hard to see that we get an (a, P)-approximate algorithm for the general case, if we use an (a, /3)-approximate algorithm for testing approximate congruence by compositions of translations and rotations in both tests. Therefore we restrict our attention to compositions of translations and rotations which are called even isometries or rigid motions [6]. Lemma

5. Let I be an even

isometry

and

I a

labeling which enable e-congruence for A and B. Let d and e be arbitrary points in the plane. There is a rotation R with center e, such that R and 1 enable approximate congruence with tolerance e t dist(Z(d)), e) for Tdr(A) and B.

Proof. Every even isometry is a composition of a translation and a rotation whose center can be chosen arbitrarily [6]. So we have I = Tdlcdj 0 R’ which is carried (we use 0 to denote composition out from right to left), where R’ is a rotation about d. We show that the rotation R = Tdr 0 R’ 0 TdJ1 with center e enables approximate congruence for T,,(A) and B with tolerance F + dist(I(d), e). Since Tde = TICdjf 0 TdcCd,, we have dist(R(T,,(a;)),

/(ai))

=dist(T,,(R’(a,)),

/(a,>)

= dq-/(d)r(J@J)~

+I))


+dist(I(d),

l(a,))


Combining

e).

Lemma

e)

q

2 and Lemma

5 we have

Lemma 6. Let I be an even isometry and 1 a labeling which enable e-congruence for A and B. There is a rotation R with center cs such that R and 1 enable approximate congruence with tolerance F + dist(I(c,), ce) < 2~ for TC,_$A> and B. Now consider 32

the algorithm

in Fig. 3.

LETTERS

(1) if TcAcB(A) and B are c-congruent center cB then return YES fi; (2) if T, /1,H(A) and B are not 2vzongruent center c8 then return NO fi; (3) return DON’T KNOW

10 August

1992

by a rotation

with

by a rotation

with

Fig. 3.

Theorem

7. The algorithm

F C,P,(A,

B), gruence

B))-approximate

by even

isometries

in Fig. 3 is a (ie,,,(A, algorithm for e-conwith time complexity

0(n4>.

Proof. By Lemma 6, TC,_$A> and B have to be 2&-congruent by a rotation with center cB if A and B are &-congruent. Thus if the test in (2) is positive, A and B cannot be &-congruent. Further, A and B are &-congruent if TC,C,(A> and B are E-congruent because TCAC, is an even isometry. By Lemma 2 there is an isometry I, such that dist(Z,(c,), c~) G E,,,~(A, B). Hence a rotation with center cg exists such that T,,,,(A) and B are approximately congruent with tolerance 2~,~[(A, B). Clearly 7jC.,CA(A) and B cannot be 2&congruent if E < ~E,~~(A, B). Hence the algorithm may be unable to give an answer only if the tolerance value lies in the interval [$E,~~(A, B), ~E~,,(A, B)). The computation of TC,C$A> takes time O(n). Approximate congruence of two points sets D=(d ,,..., d,} and E={e ,,..., e,] by a rotation with a given center c can be decided in time O(n”> [5,8]. Hence lines (1) and (2) each have time complexity 0(n4>. q Remarks. (1) If the algorithm reports DON’T KNOW, we may conclude that the best value is near eCjpr(A, B) without any knowledge of the exact value of e,JA, B). (2) The algorithm may answer YES or NO even if the test value lies in the indecision interval.

3. Time versus indecision The indecision interval can be made arbitrarily small at the expense of running time. Let y be a

Volume

43, Number

I

INFORMATION

PROCESSING

( 1) possihk + false; (2) for each ball U, of the covering do (3) Compute T,,,,(A); if T, ,1,,(A) and B are E-congruent by a rotation with (4) cent& c, then return YES ti; if T,. 1,,(A) and B are (F + y&congruent by a rotation (5) with center c, then possihk + true fi od; (6) if possihk then return DON’T KNOW else return NO fi; Fig. 4.

positive real number smaller than the test value E. Cover the ball with center cs and radius E with balls of radius y. Let I~J be the ith ball of the covering, ci be its center. Consider the algorithm in Fig. 4.

Theorem 8. The algorithm in Fig. 4 is a (y, y>-upproximate algorithm for a-congruence by ecen isometries with time complexity O(( e/yj2n”>, where y < e is an additional input parameter.

Proof. If j exists such that q.,A,, and B are &-congruent, then A and B are E-congruent, too. On the other hand, every isometry which enables &-congruence for A and B maps c,~ into the E-ball with center cg and hence in some U, of the covering. Therefore by Lemma 5 (with d = cA and e = c,> TC4(.1(A) and B are (E + y)-congruent by a rotation with center ck. Hence if there is no such k, then A and B cannot be s-congruent. This shows the correctness of the algorithm. If e < F,,,~( A, B) - y, then TC,,(.L(A) and B cannot be (E + y)-congruent. By Lemma 2 there is a ball q. that contains the image of cA under an isometry that enables congruence with tolerance E_,~( A, B). Hence by Lemma 5 a rotation with center cj exists that enables approximate congruence for TCA,,(Aj and B with tolerance F if e > cop,(A,

LETTERS

10 August

B) + y. So the interval where the algorithm be unable to give an answer is [%,,(A,

B) -Y?

1992

may

E
Since 4~~/y~ balls of radius y are sufficient to cover the E-ball with center cR, there are O(E~/~~> iterations of the loop. As in the proof of Theorem 7, each execution of the loop has time complexity 0(n4). 0 Analogously a (y, y )-approximate algorithm for testing approximate congruence by translation can be constructed. Again, the E-ball with center cu is covered by y-balls. For each center c, we test whether the translation which maps cA onto c, enables E-congruence or (F + y&congruence. We get the following theorem: Theorem 9. There is a (y, y)-approximate algorithm ,for e-congruence by translation with time complexity O((e/y)‘n’.“), where y < E is an additional input parameter.

4. Conclusions We have presented an O(n’> approximate decision algorithm for testing &-congruence of two point sets A and B in the plane which is guaranteed to give an answer if E $5 [;E,,,( A, f?), ~F,,[,~(A, B)), where F,,~,(A, B) is the smallest tolerance value permitting approximate congruence for A and B. By the use of an additional input parameter y < E we can reduce the indecision interval to [&&A, B) - y, Eclpl(A, B) + y). The latter algorithm has running time O((F/~)‘. n’). We have also presented approximate decision algorithms for approximate congruence by translation. It is important to note that the algorithms are reliable, i.e. if a decision is taken, it is correct. We have used y as an additional parameter for tradeoff between length of the indecision interval and running time. We can use the additional parameter y to reduce the size of the indecision interval repeatedly until e is outside 33

Volume

43, Number

INFORMATION

1

PROCESSING

the indecision interval. If we first test E-congruence with y = E/2, then with y = .5/d, and so on until a decision has been taken, the procedure will terminate if F # F,~~(A, B). The running time is

O((E/(E -o&k

i

min

(

(.5/(.5 - E,pf( -4, B)))‘~“Y

n8)).

Theorem 10. Approximate congruence with tolerance F of point sets A and B can be decided in time o min (

(E/(E

-E~,~(A,

B)))‘n4,

a’))-

(

Lemma 2, Lemma 3, and Lemma 5 generalize directly to higher dimensions. Hence the approximate decision algorithms for testing approximate congruence under translation generalize to higher dimensions, too. The generalization of the algorithms for the general case depends on the availability of an algorithm for deciding approximate

34

1992

congruence an isometry

for two point sets in R” enabled that fixes one point.

by

Acknowledgment

B)))2n4)

since the execution of the algorithm with the smallest value for y dominates running time. The algorithm is better than the algorithm of Alt et al. if I& -Eopl(A, B)I =fl(~/iz~>. If we Stop this algorithm after 2 log,n iterations with y = s/n2 and skip to the algorithm of Alt et al. we get an algorithm with running time 0

10 August

LETTERS

The author thanks Kurt Mehlhorn helpful discussions on this topic.

for several

References fll H. Alt. K. Mehlhorn,

H. Wagener and E. Welzl, Congruence, similarity, and symmetries of geometric objects, Discrerc Compuf. Geom. 3 (1988) 237-256. f21 M.J. Atallah, Checking similarity of planar figures, Infernut. J. Cornput. Inform.Sci. 13 (1984) 2799290. The translation square map and approxi[31 P.J. Heffernan, mate congruence. Iform. Process. Left. 39 (1991) 153-159. [41 K. Imai, S. Sumino and H. Imai, Minimax geometric fitting of two corresponding sets of points, in: Proc. of the 5th ACM Symp. on Compufafiorml Geometry (1989) 276 2x2. congruence and symmetry deEl S. Jwanowski, Approximate tection in the plane, Ph.D. Thesis. Fachbereich Mathematik, Freie Universitiit Berlin, 1990. Geometry (Springer, Berlin, [61 G.E. Martin, Transformation 1982). Data Structures and Algorithms 2: Gruph [71 K. Mehlhorn, Algorithms and NP-completeness (Springer, Berlin, 1984). Uber die Bitkomplexitat der e-Kongruenz, [XI S. Schirra, Diplomarbeit, Fachbereich Informatik, Universitat des Saarlandes, Germany, 1988.