euclidean ordering via chamfer distance calculations

10
Computer Vision and Image Understanding Vol. 73, No. 3, March, pp. 404–413, 1999 Article ID cviu.1998.0743, available online at http://www.idealibrary.com on Euclidean Ordering via Chamfer Distance Calculations St´ ephane Marchand-Maillet *,1 and Yazid M. Sharaiha* Department of Multimedia Communications, EURECOM Institute, BP 193, 06904 Sophia-Antipolis, France; Operational Research and Systems, Imperial College of Science, Technology and Medicine, 53 Prince’s Gate, London SW7 2PG, United Kingdom E-mail: [email protected] Received September 8, 1997; accepted November 24, 1998 This paper studies the mapping between continuous and discrete distances. The continuous distance considered is the widely used Euclidean distance, whereas we consider as the discrete distance the chamfer distance based on 3 × 3 masks. A theoretical charac- terization of topological errors which arise during the approxima- tion of Euclidean distances by discrete ones is presented. Optimal chamfer distance coefficients are characterized with respect to the topological ordering they induce, rather than the approximation of Euclidean distance values. We conclude the theoretical part by presenting a global upper bound for a topologically correct distance mapping, irrespective of the chamfer distance coefficients, and we identify the smallest coefficients associated with this bound. We il- lustrate the practical significance of these results by presenting a framework for the solution of a well-known problem, namely the Euclidean nearest-neighbor problem. This problem is formulated as a discrete optimization problem and solved accordingly using al- gorithmic graph theory and integer arithmetic. c 1999 Academic Press 1. INTRODUCTION The main motivation of this work is to analyze the mapping between continuous and discrete distances on the unit square grid. For a given pixel on the grid, a neighbourhood of that pixel is defined by a distance metric. The local neighbours of a pixel are contained within a mask centred at that pixel. The most commonly used is the 3 × 3 mask, where the neighbors are typically defined by the city-block distance (4-neighbors) or the chessboard distance (8-neighbours) [11]. Local distances within the mask form the basis for the computation of global distances on the grid. Chamfer distance was first introduced by Hilditch [7, 8] and studied by Borgefors in [1, 2] for the approximation of Euclidean distances on the grid. While studying in depth the calculation of Euclidean distance values using discrete distance functions (Section 2), we will derive results concerning the decomposition of integer values which can then form the basis for the development of optimal algorithms for the solution of typical problems encountered in 1 To whom correspondence should be sent. image processing (see, e.g., [9]). For highlighting the practical use of the intermediate theoretical results derived throughout, Section 3 uses these results and tools issued from graph the- ory for solving exactly the Euclidean nearest-neighbor problem (i.e., where continuous distances values are required) using inte- ger arithmetic. Nearest-neighbor problems have applications for solving different problems in image processing. The idea behind the proposed solution therefore defines an alternative context in which these problems can be solved. 2. TOPOLOGICAL ERRORS We consider throughout these pages that the continuous dis- tance used is the Euclidean distance d E defined as d E ( p, q ) = p (x p - x q ) 2 + ( y p - y q ) 2 , where p = (x p , y p ) and q = (x q , y q ). We introduce the notation for some standard functions. dx e is the smallest integer greater or equal to than x R and bx c is great- est integer smaller or equal to than x R. Then, round(x ) = bx c if bx c≤ x ≤bx c+ 1 2 . Otherwise, round(x ) =dx e. In approximating the Euclidean distance, the chamfer distance is used since it allows for algorithms to operate in integer arith- metic. We will consider chamfer distances in relation to 3 × 3 masks. We define a as the length of the unit horizontal/vertical move (a-move) on the grid, and b as the length of the unit diago- nal move (b-move) on the grid. Parameters a and b are referred to as distance transform (DT) coefficients. The chamfer distance can be computed as the length of a shortest path on the grid. Given two points p and q , the chamfer distance d a,b between p and q is calculated as d a,b ( p, q ) = k a a + k b b, (1) where k a and k b represent the number of a- and b-moves on the shortest path from p to q on the grid. The conditions on a and b for d a,b to be a distance are given in (2) below (see [10, 14] for more details). Such conditions allow d a,b to satisfy the three common metric properties: 0 < a < b < 2a. (2) 404 1077-3142/99 $30.00 Copyright c 1999 by Academic Press All rights of reproduction in any form reserved.

Upload: stephane-marchand-maillet

Post on 15-Jun-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Computer Vision and Image Understanding

Vol. 73, No. 3, March, pp. 404–413, 1999

Article ID cviu.1998.0743, available online at http://www.idealibrary.com on

Euclidean Ordering via Chamfer Distance Calculations

Stephane Marchand-Maillet∗,1 and Yazid M. Sharaiha†∗Department of Multimedia Communications, EURECOM Institute, BP 193, 06904 Sophia-Antipolis, France;†Operational Research and Systems,

Imperial College of Science, Technology and Medicine, 53 Prince’s Gate, London SW7 2PG, United KingdomE-mail: [email protected]

Received September 8, 1997; accepted November 24, 1998

This paper studies the mapping between continuous and discretedistances. The continuous distance considered is the widely usedEuclidean distance, whereas we consider as the discrete distancethe chamfer distance based on 3× 3 masks. A theoretical charac-terization of topological errors which arise during the approxima-tion of Euclidean distances by discrete ones is presented. Optimalchamfer distance coefficients are characterized with respect to thetopological ordering they induce, rather than the approximationof Euclidean distance values. We conclude the theoretical part bypresenting a global upper bound for a topologically correct distancemapping, irrespective of the chamfer distance coefficients, and weidentify the smallest coefficients associated with this bound. We il-lustrate the practical significance of these results by presenting aframework for the solution of a well-known problem, namely theEuclidean nearest-neighbor problem. This problem is formulatedas a discrete optimization problem and solved accordingly using al-gorithmic graph theory and integer arithmetic. c© 1999 Academic Press

1. INTRODUCTION

iqhsT

t

itio

n

lm

image processing (see, e.g., [9]). For highlighting the practicaluse of the intermediate theoretical results derived throughout,

the-eminte-for

indxt in

dis-

nceith-

l-

ncegrid.

4]

The main motivation of this work is to analyze the mappbetween continuous and discrete distances on the unit sgrid. For a given pixel on the grid, a neighbourhood of tpixel is defined by a distance metric. The local neighboura pixel are contained within a mask centred at that pixel.most commonly used is the 3× 3 mask, where the neighbors atypically defined by the city-block distance (4-neighbors) orchessboard distance (8-neighbours) [11]. Local distances wthe mask form the basis for the computation of global distanon the grid. Chamfer distance was first introduced by Hild[7, 8] and studied by Borgefors in [1, 2] for the approximatof Euclidean distances on the grid.

While studying in depth the calculation of Euclidean distavalues using discrete distance functions (Section 2), wederive results concerning the decomposition of integer vawhich can then form the basis for the development of optialgorithms for the solution of typical problems encountered

1 To whom correspondence should be sent.

40

1077-3142/99 $30.00Copyright c© 1999 by Academic PressAll rights of reproduction in any form reserved.

nguareatofhe

reheithinceschn

cewilluesalin

Section 3 uses these results and tools issued from graphory for solving exactly the Euclidean nearest-neighbor probl(i.e., where continuous distances values are required) usingger arithmetic. Nearest-neighbor problems have applicationssolving different problems in image processing. The idea behthe proposed solution therefore defines an alternative contewhich these problems can be solved.

2. TOPOLOGICAL ERRORS

We consider throughout these pages that the continuoustance used is the Euclidean distancedE defined asdE(p,q)=√

(xp− xq)2+ (yp− yq)2, wherep= (xp, yp) andq= (xq, yq).We introduce the notation for some standard functions.dxe is thesmallest integer greater or equal to thanx ∈R andbxc is great-est integer smaller or equal to thanx ∈R. Then, round(x)=bxc if bxc≤ x≤bxc+ 1

2. Otherwise, round(x)=dxe.In approximating the Euclidean distance, the chamfer dista

is used since it allows for algorithms to operate in integer armetic. We will consider chamfer distances in relation to 3× 3masks. We definea as the length of the unit horizontal/verticamove (a-move) on the grid, andb as the length of the unit diagonal move (b-move) on the grid. Parametersa andbare referred toas distance transform (DT) coefficients. The chamfer distacan be computed as the length of a shortest path on theGiven two pointsp andq, the chamfer distanceda,b betweenpandq is calculated as

da,b(p,q) = kaa+ kbb, (1)

whereka andkb represent the number ofa- andb-moves on theshortest path fromp to q on the grid. The conditions ona andb for da,b to be a distance are given in (2) below (see [10, 1for more details). Such conditions allowda,b to satisfy the threecommon metric properties:

0< a < b < 2a. (2)

4

S

h

De

D

e

o

l

hs

d

t

d

en

-

.

ar-of2.2,

s

ts

re

-re

cura 1

ons,er of

EUCLIDEAN ORDERING U

FIG. 1. An example of a topological error.

The number ofa- and b-moves (ka, kb) on the shortest patfrom p to q can also be used to compute the Euclidean distabetweenp andq:

dE(p,q) =√

(ka+ kb)2+ k2b. (3)

Without loss of generality, we restrict this study to values ofcoefficients such thata andbare relatively prime (i.e., the greatcommon divisor ofa andb, gcd(a, b), is such that gcd(a, b)= 1).This corresponds to normalising thea andb coefficients to theirminimal configuration.

Although different studies establish particular values ofcoefficients as optimal (e. g.,a= 3, b= 4), optimality generallyrefers to a criterion in relation to a minimum error in the aproximation of Euclideandistance valuesvia chamfer distanccomputation (see, e.g., [2, 14, 15]). In contrast, Forchham[5, 6] introduced the concept oftopological inconsistenciesin-duced by discrete distance when used as an approximatithe Euclidean distance. The inconsistency arises becausedifference in ordering of the two distance measures as widescribed next. He derived values of DT coefficientsa andbwhich are empirically shown to be optimal with regard to tcriterion. The results were based on the use of look-up tablean investigation of a limited number of values of the parameunder study.

In this section, we propose an analytical (and therefore, cplete) characterization of the optimal values ofa andb with re-spect to thetopologicalcriterion. Essentially, the ordering of thdiscrete distance does not match the ordering of the Euclidistance. Consider the following example (see Fig. 1). LetDT coefficients bea= 2, b= 3, and consider the three integpoints (pixels),p= (0, 0),q= (10, 1), andr = (9, 4). The short-est path on the grid fromp toq is given byka= 9 andkb= 1 andthat fromp to r is given byka= 5 andkb= 4. Using Eqs. (1) and(3), we haveda,b(p,q)= 21, dE(p,q)=√101, da,b(p, r )= 22,anddE(p, r )=√97. If q andr are border pixels, the discreDT will lead to considerq as the nearest border pixel top (bythe chamfer distance measure), giving an approximate Euclidistance of

√101. This is clearly incorrect since there is a sma

Euclidean distance betweenp and another border pixel (namer ) giving a Euclidean distance of

√97. In other words, since

da,b(p,q)< da,b(p, r ) anddE(p,q)> dE(p, r ), the ordering ofda,b differs from the ordering ofdE.

Given a pair of DT coefficients (a, b), we characterise theconfigurations for which this problem occurs precisely. Fir

ING CHAMFER DISTANCES 405

nce

Tr

T

p-

mer

n ofof thel be

isand

ters

om-

eeantheer

e

eanllerly,

we introduce how restrictions for the decomposition of a givdiscrete distance valueD into a- andb-moves can be given bythe solution to the Frobenius problem.

THEOREM 1 [13]. Given0<a< b such that(a, b)∈N2 andgcd(a, b)= 1. Consider the equation: kaa+ kbb= D, (ka, kb)∈N2. If χ = (a− 1)(b− 1), then we have the following instances:

(i) If D ≥χ, there is always at least one solution(ka, kb).(ii) If D =χ − 1, there is no solution.(iii) There are exactly12χ values of D that have no solution

We will use the solution to this classical problem to chacterise the topological error introduced earlier. Two typeserrors are distinguished and presented in Sections 2.1 andrespectively.

2.1. Type 1 Error

Given a pair of DT coefficients (a, b) and three integer pointp,q, andr , a Type 1 error occurs betweenq andr relative top ifda,b(p,q)= da,b(p, r ) anddE(p,q) 6= dE(p, r ). More formally,we make the following definition.

DEFINITION 1 (Type 1 error). Given a pair of DT coefficien(a, b) and a discrete distance valueD, a Type 1 topological erroroccurs if there exist two integer pairs (ka1, kb1) and (ka2, kb2) such

that ka1a+ kb1b= ka2a+ kb2b= D and√

(ka1 + kb1)2+ k2b16=√

(ka2 + kb2)2+ k2b2

.

An example for Type 1 error is illustrated in Fig. 2, whe(ka1, kb1) represents the shortest path fromp to q and (ka2, kb2)is the shortest path fromp to r . In this example, the DT coefficients area= 2 andb= 3, and the three integer points ap= (0, 0),q= (3, 0), and r = (2, 2). We obtainda,b(p,q)=da,b(p, r )= D= 6, sinceka1 = 3, kb1 = 0, andka2 = 0, kb2 = 2.On the other hand, we have,dE(p,q)= 3 anddE(p, r )=√8.

It is clear that a necessary condition for Type 1 error to ocis thatD can be decomposed in more than one manner. Lemmgives an upper bound on the number of such decompositiand Lemma 2 provides an exact upper bound on the numbb-moves (kbmax) over all possible decompositions.

LEMMA 1. Given a pair of DT coefficients(a, b) and a dis-crete distance value D∈N, there are at mostb(bD/bc + 1)/ac+ 1 configurations(ka, kb) such that kaa+ kbb= D with ka≥ 0and kb≥ 0.

Proof. Clearly,kb can take at mostbD/bc+1 values. Now,among these values, only some can satisfy the equationkaa+ kbb

st, FIG. 2. The first instance of Type 1 topological error for (a, b)= (2, 3).

E

tt

r

i

b

)

e setnte

st

t

pair

l)

the

406 MARCHAND-MAILL

= D. Let us assume that (ka, kb) is one such valid pair. ThenD= kaa+ kbb= kaa+ kbb+ab−ab= (ka+ b)a+ (kb − a)b.Then, if kb−a≥ 0, the configuration (ka+ b, kb−a) is alsovalid. Likewise, all configurations (ka+ ib, kb− ia) with i ∈Zsuch thatka+ ib≥ 0 andkb− ia≥ 0 are valid. Clearly, sincegcd(a, b)= 1, there are at mostb(bD/bc + 1)/ac+1 suchivalues. Therefore, Lemma 1 holds.

In this study, only positive pairs of coefficients (ka, kb) definevalid decompositions. This leads from the previous lemmalimited number of such decompositions. For actually computhese decompositions, the maximal value forkb is first found andnotedkbmax. From calculations derived in the above proof all dcompositions can then be found. For a given value ofD, bD/bcgives an upper bound tokbmax. The value by which both diffewill be calculated as an implicit functionψ whose derivation isdetailed in the proof of the next lemma.

LEMMA 2. Given a pair of DT coefficients(a, b) and a dis-crete distance value D, we assume that the existence condit(i) in Theorem 1 holds. Then, the maximal value kbmax of kb suchthat kaa+ kbmaxb= D with ka≥ 0 and kbmax≥ 0 is given by

kbmax =⌊

D

b

⌋− ψ((D modb) moda), (4)

whereψ is the implicit integer function:

ψ : {0, 1, . . . ,a− 1} 7→ {0, 1, . . . ,a− 1},ψ((x(2a− b)) moda) = x.

Proof. The existence of a decomposition is givenTheorem 1. The derivation of the expression forψ calls for thenumber of timesb should be added to (D modb) for this valueto be a multiple ofa. In other words, the problem of finding thmaximal valuekbmax of kb such thatkaa+ kbmaxb= D is mappedonto the problem of finding the minimal positive valuek∗ of ksuch that

(D modb+ kb) moda= 0. (5)

In this case, we have

kbmax =⌊

D

b

⌋− k∗. (6)

Consider the following implicit integer functionψ :N→N inits general form:

ψ(x) ={

k, if (x + kb) moda = 0,

+∞, if ∀k ≥ 0 (x + kb) moda 6= 0.(7)

Using the above definition and modulus arithmetic, one can eily prove the following properties forψ :

T AND SHARAIHA

,

o aing

e-

on

y

e

(i) ψ(0)= 0; (ii) ψ(x+a)=ψ(x); (iii) ψ(x+ b)=ψ(x)− 1;(iv) ψ(x+ (2a− b))=ψ(x)+ 1; (v) ψ(x)= k⇔ψ(x)=k moda. Hence, from properties (i) and (ii), we deduce thatψ

is periodic and, therefore, can be defined only forx ∈ {0, 1, . . . ,a− 1}.

Now, letk∈N andk′ ∈N be such thatk 6= k′ and (kb) moda= (k′b) moda=α. Then,∃β, γ ∈N such thatkb=α+βa andk′b=α+ γa. It follows that

(kb) moda = (k′b) moda

⇔ (k− k′)b = (β − γ )a

⇔ (k− k′)b moda = 0

⇔ (k− k′) moda = 0 since gcd(a, b) = 1.

Equivalently, if (k− k′) moda 6= 0⇔ (kb) moda 6= (k′b) moda.Therefore, the set{(kb) moda, ∀k≥ 0} contains exactlya dif-ferent values.

From property (v), we know thatψ(x)∈ {0, 1, . . . ,a− 1}.Therefore, we can claim that,∀k∈ {0, 1, . . . ,a− 1}, ∃x ∈{0, 1, . . . ,a− 1} such thatψ(x)= k.

Therefore,ψ is a bijection from{0, 1, . . . ,a− 1} to{0, 1, . . . ,a− 1}such thatψ((k(2a− b)) moda)= k. Hence, using Eqs. (5and (7), we obtain thatk∗ =ψ((D modb) moda). Therefore,combining this result with Eq. (6), Lemma 2 holds.

ψ can be easily computed as a one-to-one mapping of th{0, 1, . . . ,a− 1} onto itself. Thus, Lemma 2 readily gives aexhaustive list of (ka, kb) pairs for decomposing any discredistance valueD for any DT coefficientsa andb.

DEFINITION 2. Given a pair of DT coefficients (a, b) and adiscrete distance valueD which can be decomposed in at leaone manner, we define:

—The set2={(kai , kbi ), i = 0, . . . ,n} as the exhaustive lisof all possible decomposition pairs (i.e.,D= kai a+ kbi b, kai ≥0, kbi ≥ 0∀i = 0, . . . ,n with n=bkbmax/ac). Note thatkbmax=maxi=0,...,n kbi and,kbi = kbmax− ia. Therefore, the set2 can befully computed using Lemma 2.

—Ri (D) as the Euclidean distance associated with the(kai , kbi ). From Eq. (3), we have

Ri (D) =√(

kai + kbi

)2+ k2bi. (8)

—Rmax(D) (resp.Rmin(D)) as the maximal (resp. minimaEuclidean distance over alln+ 1 possible decompositions.

—l (resp.m) as the index in the set2 of the decomposition(kai , kbi ) (resp. (kam, kbm)), leading toRmax(D) (resp.Rmin(D)).

We now present a lemma which allows us to calculateindicesm andl (and, therefore,Rmax(D) andRmin(D)) directlyfor any DT coefficients (a, b) and any discrete distance valueD.

LEMMA 3. Given a pair of DT coefficients(a, b) and a dis-

as-crete distance value D, we assume that D can be decomposed inat least more than one manner. Then, the minimal decomposition

S

,

es

-

-

us-ce

.,si-h

to

EUCLIDEAN ORDERING U

(kam, kbm) leading to Rmin(D) is given by

m= round

(D(a− b)

a(b2− 2ab+ 2a2)+ kbmax

a

)(9)

and the maximal decomposition(kal , kbl ) leading to Rmax(D) isgiven by

l ={

0, if kbmax +(kbmax moda

)> 2D(b − a)

b2 − 2ab + 2a2 ,

n, if kbmax +(kbmax moda

) ≤ 2D(b − a)b2 − 2ab + 2a2 .

(10)

Proof. RearrangingD= kai a+ kbi b, we obtainkai = (D −kbi b)/a. Combining this with Eq. (8), we obtain

R2i (D) = 1

a2

[k2

bi(b2− 2ab+ 2a2)+ 2kbi D(a− b)+ D2

].

(11)

Given i and j in {0, . . . ,n} such thati < j , we havekbi > kbj .Then,Ri (D)> Rj (D) if

kbi + kbj >2D(b− a)

b2− 2ab+ 2a2. (12)

Now, if kbi > kbj ∀i < j , Eq. (12) shows that we have the following pattern:

R0(D) > R1(D) > · · · > Rm(D) (=Rmin(D))

< Rm+1(D) < · · · < Rn(D). (13)

Therefore,m is the first integer such thatRm−1(D)> Rm(D) andRm(D)≤ Rm+1(D),

kbmax− (m− 1)a+ kbmax −ma>2D(b− a)

b2− 2ab+ 2a2

and

kbmax−ma+ kbmax− (m+ 1)a ≤ 2D(b− a)

b2− 2ab+ 2a2.

Therefore,

D(a− b)

a(b2− 2ab+ 2a2)+ kbmax

a+ 1

2> m

≥ D(a− b)

a(b2− 2ab+ 2a2)+ kbmax

a− 1

2.

Hence, Eq. (9) holds. It is important to note thatm is uniquelydefined by the above equation. Using the result in Eq. (13)can also say that the maximum Euclidean distance is obtaine

either extreme ofi . Using Lemma 1, we obtain thatkb0 = kbmax

andkbn = kbmax moda. Therefore, using the valid inequality give

ING CHAMFER DISTANCES 407

-

wed for

in Eq. (12), we can claim that Eq. (10) completely characterizl . Hence, Lemma 3 holds.

LEMMA 4 (Characterisation of a Type 1 error).Given a pairof DT coefficients(a, b),a Type 1 error occurs for any discretedistance value D for which Rmax(D) 6= Rmin(D).

Clearly, the first instance ofD for which Rmax(D) 6= Rmin(D)is D=ab. In this case,kbmax=a, n= 1,2={(0,a), (b, 0)} (i.e.,R0=a

√2 andR1= b). Hence,Rmax(ab) 6= Rmin(ab). Therefore,

we define the following Euclidean distance limit when considering Type 1 errors only.

DEFINITION 3 (Euclidean distance limit induced by Type 1 error,R1(a, b)). Given a pair of DT coefficients (a, b), andD=abas the minimum discrete distance value for whichRmin(D) 6=Rmax(D), we define the Euclidean distance limitR1(a, b) forType 1 errors as follows:R1(a, b) is the maximal Euclideandistance value deduced from a discrete distance value (i.e.,ing Eq. (3)) up to which both discrete and continuous distanordering match. More formally,R1(a, b) is the maximalEuclidean distance valueR such that∃ ka, kb∈N such thatR=√

(ka+ kb)2+ k2b andR< Rmax(ab).

In other words,Rmax(ab) can be considered as a strict (i.enonfeasible) Euclidean distance limit. In order to obtain a feable limit, we searchD′ the maximal discrete distance value sucthatRmin(D′)< Rmax(ab) and considerR1(a, b)= Rmin(D′). Us-ing the previous study, we can easily design an algorithmcompute, for any pair of DT coefficients (a, b), the value ofR1(a, b). In Fig. 3, (R1(a, b))2 is plotted for each pair of validDT coefficients such thata≤ 10.

2.2. Type 2 Error

Given a pair of DT coefficients (a, b) and three integer pointsp,q, andr , a Type 2 error occurs betweenq andr , relative top, if da,b(p,q)< da,b(p, r ) anddE(p,q)> dE(p, r ).

nFIG. 3. Euclidean distance limit induced by Type 1 of topological error(R1(a, b))2.

t

d

t

nce

e 2

at

ne aror

ere,

is-iv-

iusr

ststyar-ingof

ntse.,

408 MARCHAND-MAILLE

FIG. 4. The first instance of Type 2 topological error for (a, b)= (2, 3).

DEFINITION 4 (Type 2 error). Given a pair of DT coefficien(a, b) and two discrete distance valuesD1 and D2, we assumethat ∃ (ka1, kb1) and (ka2, kb2) such thatka1a+ kb1b= D1 andka2a+ kb2b= D2 (see Theorem 1). A Type 2 error occurs

D1< D2 and√

(ka1 + kb1)2+ k2b1>

√(ka2 + kb2)2+ k2

b2.

Figure 4 illustrates an instance of Type 2 error betweenq andr , relative top. In this example, the DT coefficients area= 2 andb= 3. We considerp= (0, 0),q= (6, 0), andr = (5, 3). There-fore,D1= da,b(p,q)= 12, sinceka1 = 6 andkb1 = 0. We also ob-tain D2= da,b(p, r )= 13, sinceka2 = 2 andkb2 = 3. On the otherhand, we havedE(p,q)=√36 anddE(p, r )=√34. Therefore,da,b(p,q)< da,b(p, r ) anddE(p,q)> dE(p, r ).

From a geometric viewpoint, given three integer pointsp,q,andr such thatD1= da,b(p,q)< D2= da,b(p, r ), a Type 2 erroroccurs betweenq and r , relative to p, if there exists at leasone integer point (namely,r ) included in the area between thdiscrete disc of radiusD1 centred atp and the Euclidean discthat contains this discrete disc. In Fig. 4, this area is illustraby the shaded surface. A Type 2 error occurs betweenq andr ,relative top, sincer lies in this shaded surface.

The geometrical characterization of Type 2 errors will, thefore, be investigated through the characterization of the raof the smallest Euclidean disc that contains the discrete disradiusD for any given values of the DT coefficients (a, b) andfor any discrete distance valueD. The radius of such a Euclideadisc was notedRmax(D) (see Definition 2). Therefore, the geometrical characterization of Type 2 error can be formally writtas follows.

LEMMA 5. Given a pair of DT coefficients(a, b) and a dis-crete distance value D, a Type 2 error occurs in the discrete disof radius D if there exists a discrete distance value D′> D suchthat Rmin(D′)< Rmax(D).

Using this characterisation, the Euclidean distance liR2(a, b) induced by Type 2 error can be defined as follows.

DEFINITION 5 (Euclidean distance limit induced by Type 2 eror,R2(a, b)). Given a pair of DT coefficients (a, b), andD,the minimum discrete distance value for which there exisdiscrete distance valueD′ such thatRmin(D′)< Rmax(D), wedefine the Euclidean distance limitR2(a, b) for Type 2 errors asfollows:

R2(a, b)= Rmin(D′), whereD′ is the smallest discrete distancvalue such that Rmin(D′) < Rmax(D).

T AND SHARAIHA

s

if,

te

ted

re-ius

c of

n-

en

c

mit

r-

s a

In other words, if a Type 2 error occurs for the discrete distavalue D (e.g., at pointq in Fig. 4, with D= 12), we considerthe Euclidean distance limit as the valueRmin(D′), whereD′ isthe discrete distance value at the second point for which Typerror occurred (e.g., pointr in Fig. 4, andD′ = 13). In Fig. 5,(R2(a, b))2 is plotted for each DT coefficients pair such tha≤ 10.

Using the results of Sections 2.1 and 2.2, we can now deficombined Euclidean distance limit, where no topological erof any type can occur.

DEFINITION 6 (Global Euclidean distance limit,R(a, b)).Given a pair of DT coefficients (a, b), we define the globalEuclidean distance limitR(a, b) as the minimum between thdistance limits induced by both Type 1 and 2 errors. TherefoR(a, b)= min(R1(a, b),R2(a, b)).

R(a, b) represents the maximal achievable Euclidean dtance when growing topologically correct discrete discs. Equalently, given a pair of DT coefficients (a, b), for any discretedistance valueD such thatRmax(D)≤R(a, b), no topologicalerror (of Type 1 or Type 2) occurs in the discrete disc of radD. In Fig. 6, (R(a, b))2 is plotted for each DT coefficients paisuch thata≤ 10. Note that, for large values ofa andb, the limitinduced by the Type 2 error dominates.

2.3. Global Euclidean Distance Limitand Optimal DT Coefficients

Our aim now is to determine, whether an optimal pair exiamong all valid pairs of DT coefficients. We define optimalihere as the smallest integer pair of DT coefficients which guantees the maximum achievable Euclidean distance limit. Usthe results plotted in Fig. 6, we could say that, for all pairDT coefficients such thata≤ 10, the pair (3, 4) is a local opti-mum in the sense that it is the smallest pair of DT coefficiethat leads to a (local) maximum Euclidean distance limit (i.

eFIG. 5. Distance limit induced by Type 2 error.

S

.

iee

e

T

o

ah

T

-

r

is

l

s

error

e

-

e

EUCLIDEAN ORDERING U

FIG. 6. Global Euclidean distance limit for the correctness of the EDT

R(3, 4)=√17). In order to extend this result to any pair of Dcoefficients, we will use an analytical approach rather thangeometric approach which was used previously.

As suggested in Lemma 4 and Definition 3, an analytEuclidean distance limit induced by Type 1 errors can bemated byRmax(ab). Since this limit increases with the valuof (a, b), we pointed out earlier that Type 2 error dominatesgreater values of DT coefficients. Hence, we will mainly conctrate on an analytical study of Type 2 errors and finally combthe result with those of the previous study of Type 1 errors.result of this study can be stated as follows.

THEOREM 2. Euclidean distance limit and optimal DT cefficients Considering the chamfer distance da,b as a discretedistance, the maximal error-free Euclidean distance achievis√

17 and the smallest integer pair of DT coefficients tachieves this limit is(a, b)= (3, 4).

We introduce the idea behind the proof of Theorem 2.approach for deriving an analytical expression of the Eucliddistance limit for Type 2 error (i.e.,R2(a, b)) is made by decomposing the region of the plane (x, y) delimited by the linesy= xandy= 2x, by a liney= (β/α)x, where (α, β) is an integer paithat matches the conditions for being a pair of DT coefficie(see Fig. 7).

For each such pair (α, β), we characterize a Euclidean dtance limit in each subregion of the plane (x, y) delimited bythe lines y= x, y= (β/α)x, and y= 2x. Given a valid pair(α, β), and for any pair of DT coefficients (a, b) different from(α, β), two cases are possible, (i)b/a<β/α or (ii) b/a>β/α.Case (i) includes the valid integer points in the subregion bey= (β/α)x and abovey= x, whereas case (ii) includes the vainteger points in the sub-region abovey= (β/α)x and belowy= 2x. The Euclidean distance limitR2(a, b) is to be investi-

gated for the two sub-regions separately and we will refer toasRinf (α, β) andRsup(α, β) for cases (i) and (ii), respectively.

ING CHAMFER DISTANCES 409

Tthe

calsti-sforn-

inehe

-

bleat

heean

nts

-

lowid

In the example illustrated in Fig. 7,α= 3, β = 4. Then, forinstance,R2(6, 7) will include the Euclidean distance limitRinf (3, 4), since7

6 <43. Similarly, R2(5, 8) will include the

Euclidean distance limitRsup(3, 4), since85 >

43.

Hence, given a pair of DT coefficients (a, b), the Euclideandistance limit for Type 2 errors induced by (a, b), (i.e.,R2(a, b))will result from a combination of all Euclidean distance limitinduced by the pairs (α, β) in the following way:

R2(a, b) =min

(min

{(α,β)/(b/a)<β/α}(Rinf (α, β)), min

{(α,β)/(b/a)>β/α}(Rsup(α, β))

).

Proof. Given a pair of DT coefficients (a, b) and an inte-ger pair (α, β) such that 0<α<β <2α and gcd(α, β)= 1, weconsider two cases: (i)b/a<β/α and (ii) b/a>β/α. It willbecome apparent that the equality case represents a Type 1and, therefore, as noted earlier, will note be studied here.

We now investigate cases (i) and (ii) in order to obtain thEuclidean distance limits induced by each case (i.e.,Rinf (α, β)andRsup(α, β) respectively).

(i) (Characterisation ofRinf (α, β)). Since,b/a<β/α then,αb<βa. Givenγ1, γ2∈N, we can define the two discrete distancesD1=αb+ γ1a+ γ2b and D2=βa+ γ1a+ γ2b. In thiscase, we clearly haveD1< D2. According to Definition 4, aType 2 topological error occurs if

(α + γ1+ γ2)2+ (α + γ2)2 > (β + γ1+ γ2)2+ γ 22 .

Re-arranging, we obtain

γ2 >2γ1(β − α)+ β2− 2α2

2(2α − β). (14)

Moreover, from Definition 5, the distance limit induced by thcaseb/a<β/α is, therefore,

(Rinf (α, β))2 = (β + γ1+ γ2)2+ γ 22 . (15)

thisFIG. 7. Representation of the valid pairs of DT coefficients for the proof ofTheorem 2.

E

f

n

t

te

t

thet

fore

siblenceionce

ned

s

r-

410 MARCHAND-MAILL

FIG. 8. Graphical representation of the constraints (C1), (C2), and (C3).(A) β/α >

√2. (B)β/α <

√2.

Hence, the first instance for which a Type 2 error occurs is cacterised by (γ ∗1 , γ

∗2 ), a pair of positive integers which satis

the inequality in (14) (i.e., where a Type 2 error occurs) andwhich Rinf (α, β) is minimum. SinceRinf (α, β)> 0, the min-imization of Rinf (α, β) is equivalent to the minimization o(Rinf (α, β))2. If we consider the function9(γ1, γ2)= (Rinf (α,β))2= (β + γ1+ γ2)2+ γ 2

2 , we can rewrite the constrained miimization problem as follows. Given a valid integer pair (α, β),

min9(γ1, γ2)

subject to:

(C1) γ2 >2γ1(β − α)+ β2− 2α2

2(2α − β)(C2) γ1 ≥ 0

(C3) γ2 ≥ 0.

Now,9 is a positive convex quadratic function. Therefore,global (i.e., unconstrained) minimum of9 is reached in (γ glob

1 ,

γglob2 ) such that (∂9/∂γ1)(γ glob

1 , γglob2 )= 0 and (∂9/∂γ2)(γ glob

1 ,

γglob2 )= 0. Then,9 is minimum for (γ glob

1 , γglob2 )= (−β, 0).

But, sinceγ glob1 =−β <0, the global minimum (γ glob

1 , γglob2 )

does not satisfy constraint (C2). An analysis of the constrain(see Fig. 8) shows that two feasible cases can be consider

• If β/α <√

2, constraint (C1) can be removed since, in thcase, (γ ∗1 , γ

∗2 )= (0, 0) is fully characterised by constraints (C2)

and (C3), and therefore is the constrained minimum.• If β/α >

√2, constraint (C3) becomes redundant. Ther

fore, in this case, the minimum is obtained using the equties corresponding to constraints (C ) and (C ). Therefore, in

1 2 √ this case,γ ∗1 = 0 andγ ∗2 is the first integer strictly greater than(β2− 2α2)/2(2α−β).

TABLE 1Analytical Expressions of the Distance Limits

R inf (α, β)=√

(β + γ ∗1 + γ ∗2 )2+ γ ∗22 Rsup(α, β)=√

(α+ γ ∗1 + γ ∗2 )2+ (α+ γ ∗2 )2

βα<√

2 γ ∗1 = 0, γ ∗2 = 0 γ ∗1 =⌈

2α2−β2

2(β−α)

⌉, γ ∗2 = 0

2 3isation of Type 1 error, we obtainR1(2, 3)= 8. Therefore,R(2, 3)=min(R1(2, 3),R2(2, 3))=√8.

βα>√

2 γ ∗1 = 0, γ ∗2 =⌈β2−2α2

2(2α−β)

T AND SHARAIHA

har-yfor

f

-

he

sd.

is

e-ali-

In both cases,Rinf (α, β)=√

(β + γ ∗1 + γ ∗2 )2+ γ ∗2 2.

(ii) (Characterisation ofRsup(α, β)). Let us assume thab/a>β/α. Following similar analysis to case (i), we have9(γ1,

γ2)= (α+ γ1+ γ2)2+ (α+ γ 2). Again, we obtain the followingminimization problem. Given a valid integer pair (α, β),

min9(γ1, γ2)

subject to:

(C1) γ1 >2γ2(β − 2α)+ β2− 2α2

2(α − β)

(C2) γ1 ≥ 0

(C3) γ2 ≥ 0.

The global minimum of9 is (γ glob1 , γ

glob2 )= (0,−α) and violates

(C3). Therefore,

• If β/α <√

2, the minimum is obtained forγ ∗2 = 0 andγ ∗1is the first integer strictly greater than (2α2−β2)/2(β −α).• If β/α >

√2, (γ ∗1 , γ

∗2 )= (0, 0).

In both cases,Rsup(α, β)=√(α+ γ ∗1 + γ ∗2 )2+ (α+ γ ∗2 )2.We can summarize the analytical expressions for

Euclidean distance limits induced by (α, β) in Table 1 (note thain this case,dxe is the smallest integerstrictly greaterthanx).

Using these results, we can list the values of the limitsthe smallest possible values ofα andβ. Table 2 summarizes thEuclidean distance limit values obtained when comparingb/awith β/α with the first possible values ofα andβ.

From the previous results, we can deduce that each poscombination ofa, b, α, andβ creates an increasing sequewhen ordered such thatα2+β2 increases (e.g., the expressof Rinf (α, β) whenβ/α >

√2 leads to the increasing sequen√

17,√

97,√

337, . . . ,√

(β +d (β2− 2α2)2(2α−β) e)2+d (β2− 2α2)

2(2α−β) e2, . . .).Therefore, all possible Euclidean distance limits will be obtaias soon as we obtain a limit value for any range ofb/a. Usingthe two first lines in the previous table, we deduce that, for3

2 <

b/a< 2,R2(a, b)=√8, for b/a= 32,R2(a,b)=√34, for 4

3 ≤b/a< 3

2,R2(a,b)=√17,and for1<b/a< 43,R2(a,b)=√16.

As pointed out earlier,R1(a, b) increases with the valueof the DT coefficients. Hence, clearlyR(a, b)=R2(a, b) forany pair of DT coefficients (a, b) 6= (2, 3). Now, R2(2, 3)=Rsup(3, 4)=√34, since 3 > 4. From the result of characte

γ ∗1 = 0, γ ∗2 = 0

S

e

r

gh

in

fo

p

i

t

inetic

ingintThis-ug-archichtion

mlue.meptot-

s is

ob-

r

gerives to

om-thisce

ind us-the

n

s

EUCLIDEAN ORDERING U

TABLE 2Numerical Values Euclidean Distance Limits Deduced

from Table 1 for the First Instances of (α,β)

α β R inf (α, β) Rsup(α, β)

2 3√

17√

83 4

√16

√34

3 5√

97√

184 5

√25

√80

4 7√

337√

32

Therefore, the maximal Euclidean distance achievablmax{(a,b)}R(a, b)=√17. Clearly, the first pair (a, b) whichrealizes this maximum is (a, b)= (3, 4). Hence, Theorem 2holds.

In summary, we have extended the results derived fromstudy presented in Section 2. Theorem 2 states that, forDT coefficients (a, b) such that4

3 ≤ b/a< 32, the topological

order is preserved in any discrete disc of radiusD such thatRmax(D)<

√17. In the design of algorithms which requi

chamfer distances, it is wise to maintain small values ofdiscrete distances computed. In this context, the minimumcoefficients for achieving the global upper bound of

√17 is

(a, b)= (3, 4). This is emphasised by the fact that the intepair (a, b)= (3, 4) is established as a global optimum for tapproximation of Euclideandistance values.

We concentrated here in preserving the topological ordepoints when using the chamfer distanceda,b as approximationof the Euclidean distance. Other criteria exist for optimizchamfer distance coefficients. For example, when interesteapproximating Euclidean distance values (i.e., regardless otopological order induced) one may enrich the neighborhand therefore use extended chamfer distances (e.g.,da,b,c). Suchdistances are well studied in e.g., [1, 2, 14].

The above work sets the basis for studying these extendistances in the context of topological ordering. For examthe study ofda,b,c will be based on the decompositionD= kaa+kbb+ kcc. This is easily solved since, for any valid value ofkc,one may apply our technique for the decomposition ofD− kcc.From then on, optimization may be performed using a formsimilar to Eq. (8). Forchhammer [5] gives some empiricalsights to the results of this optimization when defining optimcoefficients asa= 12, b= 17, andc= 26. In that case, consistency with Euclidean distances is maintained for values be√

50.

3. NEAREST NEIGHBOR PROBLEM

In this section, we present an application framework fortheoretical results derived throughout the above study. Wedress the problem of computing the minimal distance betw

a grid pointo referred to as “reference point” and a given setgrid points0. This problem is understood in a context where t

ING CHAMFER DISTANCES 411

is

theany

etheDT

ere

r of

gd intheod

dedle,

ulan-al

-low

head-

een

cardinalityN of the set of points is a large number (e.g., pixelsan image). Moreover, we concentrate on using integer arithmwhere possible since it allows for efficient computation.

A possible solution to this problem consists in enumeratall points in0 for computing their distance to the reference poand to select the solution associated with smallest distance.operation typically requiresO(N) Euclidean distance calculations. By contrast with this complete enumeration, here we sgest operating directly a search for the closest point. This sewill be organized as follows. First, a set of candidates in whthe solution is guaranteed to be included is located. The solupoint is then searched for within this smaller set.

Intuitively, this technique becomes efficient for a problewhereN is large since it removes the dependency to this vaMoreover, using the results derived in Section 2, it will becoapparent that the size of the set of candidates is of (asymically) constant size (i.e., of orderO(1)). In that case only thecomplexity of the characterisation of the set of candidateaccounted for.

More formally, we can formulate the nearest neighbour prlem as follows.

(P) Given a reference integer pointo and a set of integepoints0, find, using integer arithmetic, a pointq ∈ 0 such thatdE(o,q)=minp∈0 dE(o, p).

Problem (P) is first reformulated in order to take advantaof the theoretical results presented in Section 2 and to arat the Euclidean distance via integer arithmetic. The idea icharacterize two discrete distance bounds,D and D′, betweenwhich a pointq which is the exact solution to (P), will be lo-cated. The objective is to minimize the number of distance cparisons in arriving at the exact Euclidean distance. Usingtechnique, the search forq is done using the discrete distanda,b(·, ·), rather than the continuous one (i.e.,dE(·, ·)). From thisformulation, we derive an exact algorithm which we expressa pseudo-code. Each step of this algorithm is then describeing a graph-theoretic approach and shown to be optimal forproblem in question.

Problem (P) can be equivalently formulated as follows. Giveo and0, let q1 be the point:

da,b(o,q1) = minp∈0

da,b(o, p).

Following the results derived earlier,q1 can be considered aan approximation of the exact solutionq. Let D= da,b(o,q1);then the solution of (P) is given by the pointq∈0 which is thesolution to the minimization problem

minp∈0

dE(o, p) subject toda,b(o, p) ≥ D ∀p ∈ 0.

Moreover,Rmax(D) gives an upper bound to the distancedE(o,q).

ofheUsing the previous characterization of topological errors(Lemmas 4 and 5), we can define another grid pointq2 as the

E

-o

r

.

o

e

h

1

-

er-l-

ath

by. Itgth

rderis-

rtexrma-ing

n asbel

seeer

rt-iuses

the1n)on-

on

ing

412 MARCHAND-MAILL

solution to

Rmin(da,b(o,q2)) = minp∈0

Rmin(da,b (o,p))>Rmax(D )

Rmin(da,b(o, p)).

In other words, if we noteD′ = dE(o,q2), q2 is the point in0closest too such thatRmin(D′)> Rmax(D). Therefore, the solution q∈0 of (P) is the solution of the constrained minimizatiproblem,

minp∈0

dE(o, p) subject toD ≤ da,b(o, p) < D′ ∀p ∈ 0.

From this new formulation, we can readily implement the flowing algorithm for the solution of Problem (P).

ALGORITHM 1.

1. Grow a discrete disc centred at o,1a,b(o, D), incremen-tally (D= 1, 2, 3 · · ·) until a point q1∈0 is met.

2. Let D← da,b(o,q1), Rmax← Rmax(D), and q←q1

3. Increase the radius of 1a,b(o, D) by 1 (D← D+ 1).4. If Rmin(D)> Rmax (i.e., D= D′) then stop: q is the solution.5. If ∃p∈0 such that da,b(o, p)= D and dE(o, p)< dE(o,q)

then, set q← p.6. Go to Step 3.

In Step 1,D is obtained as the radius of the smallest discdisc centred ato and containing a pointq1∈0. Clearly,q1 isthe point of0 with the smallest discrete distance too. In Step 2,Rmax(D) is stored andq1 is considered as an approximation of tsolutionq. Then, iteratively (Steps 3 to 6), the lower bound (iD) is increased and the new points reached by1 are evaluatedby testing whether they are better solutions than the currentq. If it is the case (Step 5),q is updated. Note that the evaluatiin Step 5 can also be done using integer arithmetic. This cacarried out by simply using the square of the Euclidean distaor using comparisons onka andkb. Finally, Step 4 tests for thupper boundD′ of the search. Clearly, Algorithm 1 resultsthe exact solution of the above formulation which is shown toequivalent to the original formulation of Problem (P). We cantherefore state the following lemma.

LEMMA 6. Given a pair of DT coefficients(a, b), a referencepoint o and a set of points0, Algorithm 1 outputs a point q whicis the exact solution of Problem(P): minp∈0dE(o, p).

Proof. Direct from the above description of Algorithm

The algorithm is now presented in a graph theoretic conwhich allows for efficiently performing each step of AlgorithmLetV ={p= (xp, yp)/xp ∈ {xmin, . . . , xmax}andyp ∈{ymin, . . . ,

ymax}}, wherexmin, xmax, ymin, ymax are such thato∈V and0⊂V . Points inV are mapped onto vertices of the grid graphG=

(V, A). An arc (p,q) exists inA between two vertices (i.e., integer points)p andq if and only ifd8(p,q)= 1 (i.e., if p andq are

T AND SHARAIHA

n

ol-

ete

hee.,

bestnn bence

inbe

.

text1.

8-neighbors). The grid graphG therefore contains all the necessary information about 8-connectivity inV . DT coefficients aredirectly mapped onto arc lengths inG. The lengthl (p,q) of thearc (p,q)∈ A is such thatl (p,q)= da,b(p,q).

In this context, discrete distance calculations can be pformed optimally by the use of well-known shortest path agorithms. More precisely, Dial’s adaptation of the shortest palgorithm from Moore [3] is used in Step 1. This algorithmsolves the classical shortest problem on a graph first solvedDijkstra [4] with the use of special data structures (buckets)iteratively computes the discrete distance label (i.e., the lenof the shortest path to the rooto) of the neighbors of the vertexwhich have been found to have the smallest such label. In oto optimize this process, it groups vertices with the same dtance label in the same bucket. Once all neighbors of a vehave been updated, the label of the vertex is marked as penent. Therefore, since we readily obtain a topological orderof the vertices, a discrete disc of radiusD can simply be char-acterized as the set of permanently labelled vertices, as soothe algorithm attempts to update a vertex such that its new lais strictly greater thanD. This algorithm is also known to beoptimal in terms of the search time for the shortest path ([3] for more details). Therefore, in Step 1, we obtain the uppboundq1 in an optimal number of integer operations.

According to Lemma 3,Rmin(D) and Rmax(D) can be ob-tained directly in Steps 2 and 4. Continuing with Dial’s shoest path algorithm, it is straightforward to increase the radof 1 by one. During this operation, only neighboring verticof the vertex contained in the current discrete disc1 have tobe considered (i.e., vertices in theD-labelled bucket). We canthen readily perform the evaluation described in Step 5 onnewly labelled vertices. It is important to note that Algorithmcan be completely and directly (i.e., without any modificatioachieved using the above graph theoretic approach. In this ctext, Lemma 6 is therefore still valid. In other words, the solutifound is the exact solution of Problem (P).

We now present an example based on Fig. 9. FollowTheorem 2, we seta= 3 and b= 4. The points of0 are

-FIG. 9. An example application of Algorithm 1.

S

l

y

,

netecr

i

wi

w

i

dd

c

aw

d

cteslue.tste

nlowing

won-sh anar-

arch

g,

n-,

itedis,

v.

or

97

nce

ns,

EUCLIDEAN ORDERING U

surrounded by a shaded square. The algorithm goes as folA discrete disc1 is first increased toq1 (Step 1). In Fig. 9,the pointsp such thatd3,4(o, p)≤ d3,4(o,q1) are represented bblack dots (•). Therefore (Step 2), we obtainD= d3,4(o,q1)=47. Rmax can then be calculated,Rmax= dE(o,q1)=√265. Suc-cessively (Step 3),D is increased. This leads to check (Stepthe points labelleds (D= 48), h (D= 49),⊗ (D= 50), and♦ (D= 51), and not beyond sinceRmin(52)=√272> Rmax.Therefore,D′ = d3,4(o,q2)= 52 (pointq2 is not actually usedbut it is indicated by a star (∗) on Fig. 9). ForD= 48, p1 isfirst found to be a solution (dE(o, p1)=√250). ForD= 49, p2,is found to be closer too than p1. No other point from0 areto be investigated, therefore,q= p2 is the exact solution withdE(o,q)=√245.

Algorithm 1 results in the exact solution of Problem (P). Givena pointo and using discrete distance calculations, Algorithmsolves exactly the problem of minimizing the Euclidean distabetweeno and a given set of points0. Since the search for thsolution is done using discrete distances, we can use inarithmetic. It should be noted that the graphG is sparse sincthe number of arcs is at most 8 times the number of vertiMoreover,G need not be constructed explicitly since its aare defined by increments on vertex coordinates. In this conthe overall complexity of our procedure isO(n), wheren is thenumber of vertices (i.e., the cardinality ofV). The efficiency ofthis procedure will therefore augment with the density of poof 0 in V (i.e., when the ratioN/n is high).

Other procedures exist for solving the nearest neighbor plem using integer arithmetic. They are typically based onorganized comparison of squared Euclidean distances betpoints in0. Such procedures are often proved to be optimalgeneral context. The aim of the above development is therenot to replace any of these procedures but rather to show hotermediate results derived during the theoretical study presein Section 2 can be applied in this context. In a broader vthis enlarges the set of applications of shortest path searchproblems where the distance used is the Euclidean distanc

4. CONCLUSION

In this paper, the problem of approximating continuoustances by discrete ones was considered. We considereEuclidean distance in the continuous space, whereas the cfer distance based on 3× 3 masks (i.e., using the DT coefficien(a, b)) was used in the discrete space. We formally charaized the topological errors which occur during the mappingdistances from the discrete to the continuous space. Distlimits up to which these errors are guaranteed not to occurderived for any pair of DT coefficients. Among all DT coeficients, an optimal integer pair was characterized and shanalytically to correspond to a global optimum. As a by-prodof this study, we obtained results which give, without the nee

enumeration, all possible decompositions of a discrete distavalue into a combination of moves on a shortest path on the

ING CHAMFER DISTANCES 413

ows.

5)

1ce

eger

es.cstext,

nts

rob-aneen

n afore

in-ntedew,es toe.

is-the

ham-tster-ofnceere

f-ownuct

of

(ka, kb). We also obtained a result which allows for the direcomputation of the maximal and minimal Euclidean distancinduced by such decompositions for any discrete distance vaWe formalise the results by obtaining optimal DT coefficienin terms of the topological ordering they induce on the discregrid, in contrast with optimality in terms of the approximatioerror of continuous distance values. These results also alfor further understanding of errors made when approximatEuclidean distances by discrete ones.

From a practical point of view, we detailed an example of hointermediate results derived throughout could be used for cstructing an different approach for solving efficiently problemwhere Euclidean distance measurements are required. Sucapproach has been successfully applied (e.g., [9, 12]) and wrants further investigation.

ACKNOWLEDGMENTS

This work is supported by the Engineering and Physical Sciences ReseCouncil (EPSRC), UK, under Grant GR/J85271.

REFERENCES

1. G. Borgefors, Distance transformations in arbitrary dimensions,Comput.Vision Graphics Image Process.27, 1984, 321–345.

2. G. Borgefors, Distance transformations in digital images,Comput. VisionGraphics Image Process.34, 1986, 344–371.

3. R. B. Dial, Algorithm 360: Shortest path forest with topological orderinCommun. ACM12, 1969, 632–633.

4. E. W. Dijkstra, A note on two problems in connexion with graphs,Numer.Math.1, 1959, 269–271.

5. S. Forchhammer,Representation and Data Compression of Two-Dimesional Graphical Data, Ph.D. thesis, Technical University of Denmark1988.

6. S. Forchhammer, Euclidean distances from chamfer distances for limdistances, inProceedings, VIth Scandinavian Conf. on Image AnalysOulu, Finland, 1989, pp. 393–400.

7. C. J. Hilditch, Linear skeletons from square cupboards, inMachine Intel-ligence(B. Meltzer and D. Mitchie, Eds.), pp. 403–420, Edinburgh UniPress, Edinburgh, 1969.

8. C. J. Hilditch and D. Rutovitz, Chromosome recognition,Ann. New YorkAcad. Sci.157, 1969, 339–364.

9. S. Marchand-Maillet and Y. M. Sharaiha, A graph-theoretic algorithm fthe exact solution of the Euclidean distance mapping, inProceedings,Xth Scandinavian Conf. on Image Analysis, Lappeenranta, Finland, 19,pp. 221–228.

10. U. Montanari, Continuous skeletons from digitized images,J. Assoc. Com-put. Mach.16, 1969, 534–549.

11. A. Rosenfeld and J. L. Pfaltz, Distances functions on digital pictures,PatternRecognit.1, 1968, 33–61.

12. Y. M. Sharaiha and N. Christofides, A graph theoretic approach to distatransformations,Pattern Recognit. Lett.15, 1994, 1035–1041.

13. J. Sylvester, Mathematical questions with their solutions,EducationalTimes41, 1884.

14. E. Thiel and A. Montanvert, Chamfer masks: Discrete distance functiogeometrical properties and optimization, inProceedings, XIth Int. Conf. onPattern Recognition, The Hague, The Netherlands, 1992, pp. 244–247.

ncegrid

15. J. H. Verwer, Local distance for distance transformations in two and threedimensions,Pattern Recognit. Lett.12, 1991, 671–682.