Discrete distance operator on rectangular grids

Discrete distance operator on rectangular grids

Pattern Recognition Leners ELSEVIER Pattern RecognitionLetters 16 (1995) 911-923 I Discrete distance operator on rectangular grids D. Coquin *, Ph...

603KB Sizes 0 Downloads 29 Views

Pattern Recognition Leners ELSEVIER

Pattern RecognitionLetters 16 (1995) 911-923

I

Discrete distance operator on rectangular grids D. Coquin *, Ph. Bolon Laboratoire d'Automatique et Microlnformatique lndustrielle, LAMI1/ CESALP, Universit~ de Savoie, BP 806, F. 74016 Annecy Cedex, France

Received 16 June 1994; revised 10 March 1995

Abstract

In this paper we present a new local distance transformation adapted to rectangular grids. This situation occurs with most industrial vision systems. Such operators allow Euclidean distance transform images to be approximated by using only local operations. These operators are optimized in the context of minimizing the maximum error over circular trajectories. The formulas of the coefficients as a function of the pixel width are given in the case of a 5 × 5 neighborhood. Experimental results and comparisons with other distance operators are then presented. Keywords: Distance transformation;Local distance; Chamferdistances; Rectangular grid

1. I n t r o d u c t i o n

In image analysis, measuring distances between objects is often essential. The notion of distance is very useful to compute granulometries, to describe a pattern in a digital image, and to estimate the distance between objects. Most industrial vision systems digitize images with sampling steps which are different, depending on whether they are in rows or columns. Hence images are digitized on a rectangular grid. The optimization of distance transform operators should be reconsidered in that context. Pseudo-Euclidean distance transformations on rectangular grids were studied by Bolon et al. (1992), using an optimization approach similar to (Borgefors, 1986). In this paper we consider the minimization of the error between the Euclidean distance d E and the local distance d E over circular trajectories (Verwer, 1991) rather than linear ones (Borgefors, 1986; Thiel and Montanvert, 1992). It should be noticed that vector distance transforms (Danielsson, 1980) can be adapted to the case of rectangular grids (Mullikin, 1992). However, this technique requires more memory space. There is a trade-off between accuracy and computation time. Moreover, the value of the maximum relative error depends on the arrangement of the feature pixels (Mullikin, 1992). In Section 2, formulas of optimal coefficients are presented in the case of a 5 × 5 neighborhood. In Section 3, the performances of the operator are studied. In Section 4, we compare the results obtained by this operator with those obtained by Borgefors, Thiel and Verwer in the case of a square grid.

*

Corresponding author. Email: [email protected]

0167-8655/95/$09.50 © 1995 Elsevier Science B.V. All rights reserved SSD1 0167-8655(95)00033-X

D. Coquin,Ph.Bolon/ PatternRecognitionLetters16(1995)911-923

912

2. L o c a l d i s t a n c e o p e r a t o r o n r e c t a n g u l a r g r i d s

As shown in Fig. 1, the pixel size is characterized by its height H and its width L. Without loss of generality, we assume that H = 1 and L >/1. With local operators, global distances in the image are approximated by propagating local distances, i.e. distances between neighboring pixels. The distance transform image can be obtained with either a sequential or a parallel algorithm (Rosenfeld and Pfaltz, 1966, 1968). In this section we present the optimization of the coefficients of a 5 X 5 operator. Since pixels are rectangular, the operator is defined by 5 coefficients (see Fig. 1). The objective is to approximate the real Euclidean distance d E. The optimization criterion consists of minimizing the maximum error between the so-called local distance d L and the Euclidean distance d E. Unlike (Borgefors, 1986), we consider a circular trajectory rather than a linear one.

2.1. Coefficient optimization 2.1.1. Real coefficients Let pixel P be the origin of the digitized image. Let x and y be the coordinates in the image referential. Let pixel Q(x, y) describe a circle having radius R. The equation of the trajectory is (Lx) 2 + y2 = R 2. We assume that R is very large with respect to L, so that the displacement between two adjacent pixels can be regarded as continuous. Coefficients a-e must satisfy the following triangular inequality constraints:

a
b
c
d
(1) (2) (3)

Under these conditions, one can choose an optimal path between pixels P and Q, which is composed of two discrete line segments (Montanari, 1968). Arrows in Fig. l(b) are related to the elementary displacements allowed by the operator. A cone is a set of pixels located between the lines defined by two adjacent elementary displacements (say D 1 and D2). In this cone, optimal paths are a combination of elementary displacements D 1 and D 2 only. For reasons of symmetry, we consider only the case x >t 0 and y t> 0. The local distance d L is given by the following equations: for O
dL(P, Q) dL(P, Q) alL(P, Q) dL(P, Q)

= a ( x - 2 y ) + b y = y ( b - 2 a ) +xa, for x/2<~y<~x, =c(2y-x) +b(x-y) =y(2c-b) +x(b-c), for x<<,y<~2x =c(2x-y) +d(y-x) =x(2c-d) +y(d-c), for2x<~y~R, = e ( y - 2 x ) + d x = x ( d - 2 e ) +ye. For example, Eq. (7) corresponds to the path PQ in Fig. l(a) (dashed line). Y

(4) (5) (6) (7)

Second Octant

It ~. . . . ~ - - - ~ . . . . r - - - 2 - - ~ - ; ,~- .- -. -...- , - ~ -., ., -...- .- ,.-,. - - - , fl-j. . . . ~,--,..-.

i .~ .y=,x. . . . . . ~-_: Y ........ . .

Y .¢.;..~......

~-

, .

v.

.

o

I. . . . .

v. l~ rsat~.~ant ~

.

.

.

.

.

.

,___. ~_

----

-

j

--

-

,r j .... I .... .................... I

I~x

.

.

.

! --

g -I - - - - J ..I

, .........

I

j . . . .

I

j

, I

b/

a/ Fig. 1. (a) Minimal path between two pixels. (b) The 5 x 5 neighborhoodmask on a rectangular grid. The local distances a, b, c, d, and e are to be optimized.

D. Coquin,Ph. Bolon/ PatternRecognitionLetters16 (1995)911-923

913

The approximation error d L - d E is a continuous function with respect to x or y. The extrema of this function are obtained either at the extremity of the above-mentioned intervals (Fig. l(a)) or at a point where its first derivative is equal to 0. The optimization procedure must be performed in both the first and second octant, producing two optimal values, Caopt and C2opt, for coefficient c. Because of the shape of the grid, the maximum error occurs in the second octant. Therefore we choose the second value C2opt. The maximum absolute e r r o r Ema x = [ d E - d E [ is proportional to the radius R. It is given by

1

-2L2+2L~/L2+(VI-ff + 4 - 2 ) 2

Emax~-~" --

R.

(--"~ ~--4 7 ~ ~

(8)

The optimal coefficients are given by Eqs. (9)-(13) below. -2L+2L~l+( aopt bop t -~-

41/~+1

-2L) 2

(41/_~+1_2L)2 aopt4 ~

(9) (10)

+ 1/L

-2L2 + 2L~/L2 + (1/~ + 4 - 2) 2 e°pt=

(11)

(gt~ + 4 _ 2) 2

dopt = eoptZ 2 ~ ~

(12)

C°pt =

dopt(2 + L 2) - (2L2)/1/L-g+ 1 + L 2 + 4 - L Z / ( L 2 + 1)

A=

dopt(2+L 2)

(13)

with L~I/L1/L1/L1/L ~1/L1/~ -

L2+4

L~+I

d2opt(L2+l)-(2L) 2)

(14)

(See Appendix A, for more mathematical details.) Example. L = 1.4 is a typical pixel width obtained with an industrial digitizing system. The coefficients of the local operator are: a -=- 1.3896,

b -= 2.9512,

c ~ 1.7136,

d ~- 2.3835,

e -= 0.9763.

(15)

The maximum normalized error is

Emax/R = 0.0236.

(16)

2.1.2. Special case: square grid If we set L = 1 (square grid), the coefficients of the local operator become a = e = 0.9864,

b = d ~- 2.2057,

c 1 = c 2 = 1.4079.

(17)

The maximum normalized error is

Emax/R = 0.01356.

(18)

914

D. Coquin, Ph. Bolon / Pattern Recognition Letters 16 (1995) 911-923

These coefficients, except coefficient c, are similar to the ones obtained by Verwer (1991), who used a variational technique. The coefficients obtained by Verwer are a v = e v ----0.9859,

b v = d v -~ 2.2058,

c v ~- 1.3951.

(19)

2.2. Constrainedcoefficients If we set a = L and e = 1, the distances corresponding to vertical or horizontal trajectories are estimated without error. By using the same approach as in Section 2.1, we obtain the following expressions. ac_ o p t

-~"

L

(20)

be_opt=(2L(4L2+l)-2 4 f ~ + l

+~l)/4L

2

(21)

ec_opt = 1

(22)

do_op,= 2

~

+

~

/ 1

do_o~,(2 + L~) - ( 2 L V ~ C~_o,t =

(23)

+ 1) + ~

(L ~ + 4) - L~/(L ~ + 1)

(24)

with "4, = (4L 2 + 5 ) ( 4 L 2 + 1) z - (4L z + 1) 3 + ( - 8 L ) ( 4 L 2 + 1) 4f~5 + 1 2/2 '42-- 2

,43=

2_(4_3/.

(25)

2) 1

~

(26)

L2+4

( dc_opt(Zq-Z 2)

2L2 )2 ((LZ+l)dZ_ovt_4L2)( L z + 4

L2)

L2 +----~

(27)

The maximum normalized error is given by EcmaxR = ~4dc-°Pt

1 .

(28)

(See Appendix B, for more mathematical details.)

2.3. Integer approximation In most cases, it is preferable to use only integer coefficients, for reasons of time consumption and memory availability. Integer approximation of coefficients can be obtained by using an integer scaling coefficient N and rounding to the nearest integer. Let A . . . . . E denote the integer coefficients. We have X = round(x. N )

for x = a . . . . . e.

(29)

Since the maximum error is a continuous function of the ratios X/Y with X, Y = A . . . . . E, the actual maximum error (with integer coefficients) tends to the theoretical error (with real coefficients) as N tends to infinity. However, the scaling factor N has to be limited for practical reasons. Let Dim X Dim be the dimension of the digitized image and i the number of bits used for coding a pixel of the distance image. The maximum distance between two pixels of the digitized image is Areax =

Dim. C.

(30)

D. Coquin, Ph. Bolon / Pattern Recognition Letters 16 (1995) 911-923

915

We must have D i m . C = D i m . round( c . N ) = D i m . c. N < 2 i.

(31)

Hence, the scaling factor must satisfy: N < Nmax = 2 i / ( D i m . c ) .

(32)

Moreover, the integer coefficients A , . . . , E must verify the inequalities (1)-(3). Example. Dim = 512, L = 1 (square grid) and i = 16 bits. Eq. (32) yields Nmax = 90. Inequalities (1)-(3) are satisfied for N = 5, 6 and for N t> 8. The best integer approximation is obtained with N = 73. The integer coefficient values are A = 72,

B = 161,

C = 103,

D = 161,

E = 72.

(33)

Using these coefficients and scaling factor N = 73, the maximum normalized error between the local distance and the Euclidean distance is 0.01369. It should be noticed that the error produced by the integer approXimation operator is very close to that of the real coefficient optimal operator. With L - - 1 . 4 , Eq. (32) yields N m a x = 74. Inequalities (1)-(3) are satisfied for N >~ 7. The best' integer approximation is obtained with N = 42. The integer coefficient values are A = 58,

B = 124,

C = 72,

D = 100,

E = 41.

(34)

Under these conditions, the maximum normalized error is 0.0247.

3. Performance study In this section, we analyze the performances of the distance operator, in terms of maximum error and of anisotropy. We compare the results obtained by the optimal operator (real coefficients) and by its integer approximations. In the latter case, the distances are normalized by the scaling factor N. For large values of N, the maximum error is close to the theoretical error, and occurs in the last portion A22 (Fig. 5). The maximum error of the optimal operator is given by Eq. (8) or Eq. (28) in the case of constrained coefficients. As for the integer approximation operators, errors are calculated at the extremities of eacll part of the circle defined by relations (4)-(7) (see Fig. 5) and at points where the first derivative of the error is equal to zero. The maximum value of these errors is then determined. 3.1. Maximum error between local distance and Euclidean distance

Since the error is proportional to the radius R of the circular trajectory, we can study the normalized maximum error Emax/R. Figs. 2 and 3 show the influence of the pixel width L. The trend is an increase of the maximum error with L. The curves corresponding to the integer approximation operators are more irregular because of the effect of rounding the coefficients. In fact, the scaling factors were chosen so that the error is minimized for L = 1 (square grid). As can be shown in Fig. 2, the effect of the choice of the optimization criterion is more sensitive for larger values of L. 3.2. Anisotropy

The anisotropy of these operators can be described by studying the angular distribution of the error between the local distance d L and the Euclidean distance d E. For this purpose, we consider a reference trajectory

916

D. Coquin, Ph. Bolon / Pattern Recognition Letters 16 (1995) 911-923

F~dR

Emax/R

0.06 integer approximation N=73

0.05

0.05 real. coeff..

0.04

"....

constrained o~rator

---~A~

0.04 0.03

0.03 0.02 0.01

Constrained operator integer approximation N=36

0.06

0.02 1.0

I 1.2

ll.4

ll.6

11.8

L ~

: 2.0

oveF a circle L

0.01 1.0

11.2

11.4

11.6

1'8

2'.o~

Fig. 2. Maximum normalizederroras a function of pixel width L; 5 × 5 local operator. Fig. 3. Maximumnormalizederroras a function of pixel width L; 5 × 5 local operator, constrained coefficients. Relat ve Error 004

L = 1.70 "---

.....

L = 1.33

002 0.o

~

L=I

-0.02 ~0

i 40

I'

I

~0

80

~

Angle ID(degree)

Fig. 4. Relative errorversus angular position. Radius = 200 - optimum real coefficients. consisting of a discrete circular arc. The radius of the circle is large enough (R = 200) so that the effects of spatial discretisation can be neglected. The circle is generated by means of a Bresenham algorithm. Fig. 4 shows the relative error ( d L - d E ) / d E as a function of the angular position and for different pixel widths. The arc of the circle is composed of 4 parts (Fig. 5) corresponding to the inequalities of Eqs. (4)-(7). Within each part, curves are concave functions. The anisotropy of the local distance operator results in a distortion of the shape of the balls with respect to the circle. It can be characterized by studying the range and the asymmetry of the error within each portion of the circle, All . . . . . A22. It can be shown (see Tables 1 and 2) that the maximum error occurs in the portions A21 and A22 and that the asymmetry increases with the pixel width L (Fig. 4). Imax(error) + min(error) I

Asymmetry =

2R

(35)

max(error) - min( e r r o r ) Range =

(36)

R

Y i

A22

i !iiiiiiiiii!iiii i !!

y=2x

y:x

i--.

-.,---.2:1:2I . x Fig. 5. Four portions o f the arc o f the circle.

D. CoquirgPh. Bolon/ PatternRecognitionLetters16 (1995)911-923

917

Table 1 Error asymmetry for different values of pixel width L L = 1.00

L = 1.33

L = 1.70

0.0000 0.0044 0.0044 0.0000

0.0000 0.0016 0.0089 0.0000

0.0000 0.0007 0.0158 0.0000

Table 2 Error range for different values of pixel width L L = 1.00

L = 1.33

L = 1.70

Portion All Portion Aiz Portion A21 Portion A22

0.0162 0.0115 0.0234 0.0438

0.0103 0.0082 0.0317 0.0633

Portion All Portion Al2 Portion A21 Portion A22

0.0271 0.0175 0.0175 0.0271

3.3. Metricity For any pixel pair ( P , Q) d E ( P , Q) = 0

if and only if

d L ( P , Q) = dL(Q, P )

P = Q,

because of the symmetry of the coefficient mask.

For any triple ( P , Q, R) d E ( P , Q) ~< d E ( P , R) + dE(R, Q ) . (a) If R = P or R = Q, the above-mentioned inequality is satisfied. (b) Let R 4= P and R 4: Q. Let C be the cone containing segment PQ. Let D 1 and O 2 be the elementary displacements defining cone C. Such displacements are described by arrows in Fig. l(b). Because of inequalities (1)-(3), there is an optimal path H 0 between P and Q, which is a combination of the displacements D 1 and D 2. Let us consider the discrete path PRQ. If at least one of the two segments PR or RQ does not belong to the cone C, the discrete path PRQ is not a combination of the displacements D 1 and D E only. Hence, it cannot be shorter than /70 . If the two segments PR and RQ belong to the cone C, we can assume without loss of generality that this cone is in the first quadrant (Fig. l(a)). Let 61 (resp. 62) be the coefficient related to the displacement D 1 (resp. De). According to Eqs. (4)-(7) we have d E ( P , Q) = (x 0 -Xp) 3 ( 6 1 , 6z) + (Yo -YP) B ( 6 1 , 62),

(37)

dE(P, g ) = ( x R - - X P ) A ( 6 1 , 6 2 ) + ( Y R - Y P ) B ( 6 1 , 62),

(38)

dL(R, Q) = (Xa --XR) A(61, 62) + (Yo --YR) B(61, 62)

(39)

where A and B are linear functions of 61 and 62, and (xe, yp), (XQ, yo), ( x R, YR) are the coordinates of the pixels P, Q and R respectively. Therefore, we obtain alL(P, Q) = dL( P , R) + dL( R , Q).

D. Coquin, Ph. Bolon /Pattern Recognition Letters 16 (1995) 911-923

918

Table 3 Performances of different local distance operators (integer coefficients) Approach

Neighborhood

Coefficients

Scaling factor

Maximum relative error

Relative error range

Borgefors/Thiel Optimal operator Boregefors/Thiel Verwer Optimal operator Thiel Optimal operator

3X3 3×3 5 X5 5 X5 5X5 7X7 7X7

3-4 24-34 5-11-7 17-38-24 72-161-103 12-38-29-43-17 67-210-149-240-84

3 25 5 17.2174 73 12 67

5.40% 4.00% 1.98% 1.43% 1.37% 1.38% 0.89%

10.63% 8.00% 3.55% 2.81% 2.71% 2.00% 1.75%

4. Comparative study In this section we compare the results produced by the new distance operator with those obtained according to the approaches of Borgefors (1986), Thiel and Montanvert (1992) and Verwer (1991). Of course, this comparison can be conducted in the case of a square grid only. Finally, we analyze the effect of the optimization criterion, in the context of rectangular grids.

4.1. Square grid (L = 1) The integer coefficients used are listed in Table 3. The scaling factors are chosen so that a 512 × 512 distance image can be coded with 16-bit words (see Section 2.3). As far as the maximum error and symmetry are concerned, the best results are obtained with the new optimal operator. The same study was conducted for neighborhood sizes ranging from 3 X 3 to 7 x 7 (Coquin and Bolon, 1993; Coquin, 1994). The results are summarized in Table 3. The reason why the performances obtained by the new operator and by Verwer's one differ lies mainly in the scaling factor. However, since the diagonal coefficients (c) differ, a difference in the asymmetry parameter will appear as the scaling factor increases. It should be noticed that choosing an appropriate 5 X 5 operator allows performances to be similar to those obtained by the 7 × 7 operator proposed by Thiel and Montanvert (1992).

4.2. Influence of the optimization criterion Most of the optimization approaches followed in the literature use a rectilinear reference trajectory (horizontal or vertical line) rather than a circular one. Let dL,L (resp. dL,c) be the local distance calculated by using on operator optimized over a linear (resp. circular) reference trajectory (Bolon et al., 1992). Fig. 6 shows the relative difference (dL, c -- dL,L)/d E as a function of the angular position. This difference increases with the

D/~ferenee

0.6050 0.0025 O0 -0.0025 4).00 -0. 0.0

L=I..~

L=I.O

15

30

L = ~

AaI#e : ~ (degree) 45

60

75

90

Fig. 6. Difference between the two operators as a function of the angular position.

919

D. Coquin, Ph. Bolon / Pattern Recognition Letters 16 (1995) 911-923

pixel width L. Moreover, it was noticed that the location of the extrema of the error is modified. As far as the anisotropy is concerned (see Section 3.2), we notice that the new optimization criterion yields better results.

5. Conclusion In this letter, a distance operator adapted to rectangular grids is introduced and its integer approximation discussed. The main interest of such an operator is that it can be used for shape splitting, granulometry computation or pattern recognition without requiring any resampling process. Unlike the approach followed by Thiel and Montanvert (1992), which is purely discrete, we consider here continuous displacements. Thus, the model used for calculating the maximal error is valid if the distances are large with respect to the pixel size. For the sake of simplicity our presentation focused on 5 × 5 operators. In fact, the same approach was used also for 3 x 3 and 7 × 7 operators.

Appendix A. Real coefficients Let point Q(x, y) describe a circular trajectory having radius R = tx2L 2 + y 2 . We assume that R is very large with respect to L, so that the displacement between two adjacent pixels can be regarded as corLtinuous. The local distance dE(P, Q) is given by the following equations.

First octant: dE(P, Q) = a( x - 2 y ) + by = y ( b - 2a) + xa

if 0 <~y <~R/4gr-~ + 1

dL(P,Q)=b(x-y)+c(Ey-x)=y(Ec-b)+x(b-c)ifg/4~+1

~
(gl) (A2)

Second octant: alL(P,

Q) = d~ + e ( y

- 2x) = x ( d - 2e) + ye

dL(e, Q) =d(y-x) +c(2x-y) =x(2c-d) + y(d-c)

if 0 <~x <~R / V ~ + 4

(A3)

if R/X/-~ + 4 <~x <~R/l/-ff + 1

(A4)

In the first octant (resp. second octant), the error E = d L - d E is a continuous function of y (resp. x), and is piecewise derivable. Let E l l . . . . . E 2 2 be the error within each portion of the circle, All . . . . . A22 (see Fig. 5). The expressions of these errors are as follows.

First octant." I g 2 _y2 E , l ( y ) = y ( b - 2a) - a

ifO<.y<~R/ 47~+1

R

L

(AS)

Ri-S_ y2 E12(Y ) = y ( 2 c - b )

+(b-c)

L

R

if R / 4 f ~ 5 + 1

<~y<~RV~+l

(A6)

Second octant." EEl(X ) =X(2C-- d) + ( d - c ) I R 2 - (xL) 2 - R

if R/X/-~ + 4 <~x <~R/X/~+ 1

(A7)

E22(X ) = x ( d

if O <~x ~ R/~/-~ + 4

(A8)

--

2e) + eIR 2 - (xL) 2 - R

920

D. Coquin, Ph. Bolon / Pattern Recognition Letters 16 (1995) 911-923

The absolute maximum of (A5) is a measure of the optimality of the distance transformation. The aim is now to establish the values of a and b, so that the maximum error is minimized. The extrema of the error are obtained either at the extremity of the above-mentioned intervals or at the point where its first derivative is equal to zero. For y = 0, the error is Eul=R For y =

-1

.

(A9)

R/4f~ + 1, the error is R

Ell 2 =

(b - 4 f ~ + 1 ).

(A10)

The best derivative is ~Ell

Y

2a2L~_y2 O--7 The extremal value occurs for E~l(y)= 0, i.e. for = ( b - 2a) -

(All)

R L ( b - 2a) (A12)

Y + (b - 2a) 2

Inserting (A12) into (A5) and simplifying the resulting expression gives the value of the error Ell 3 = R

L

-1

.

(A13)

We follow the same approach with Eq. (A6) which yields expressions of the error. For y = + 1, the error becomes

R/~

El21_ 4L21//~R (b _ 4vF~-+ 1 ) = El12 . For y =

R~~

E12 2 =

(A14)

+ 1, the error becomes

g

(c - ~

1 ).

(A15)

Another value y is obtained if the derivative of EaE(y) is equal to zero. Inserting this expression of y into (A6) and simplifying the resulting expression gives the value of the error

E123=R(~(b-c)2+L2(2c-b)2L- 1 ) .

(A16)

We follow the same approach with Eqs. (A7) and (A8) which yields the expressions of coefficients d and e. For x = 4, the error is

R~V~ +

E211 For y = R ~

R

(A17)

1, the error is R

E212

(d- 1/~+ 4).

L2V/~-~

( c - ¢ ~ + 1) = e , : : .

(Aa8)

D. Coquin, Ph. Bolon / Pattern Recognition Letters 16 (1995) 911-923

The extremal value occurs for

E~l(x) =

0, i.e. for

R(2c-d) X ~

L¢(2c-

d) 2 + t 2 ( d -

921

(A19) c) 2

Inserting (A19) into (A7) and simplifying the resulting expression gives the value of the error E2, 3 = R (

¢(2c - d)2 + L2( d -

-1) .

(A20)

We follow the same approach with Eq. (A8) which yields the expressions of the error. For x = R~ V ~ + 4, the error is E221 --

R

(A20

( d - X/if+ 4 ) .

For x = 0, the error is E222 = R( e - 1).

(A22)

Another value y is obtained if the derivative of E22(x) is equal to zero. Inserting this expression of x into (A8) and simplifying the resulting expression gives the value of the error

E223=R( ¢(d-2e)2+(Le)2

)

- 1 .

L

(A23)

Optimal values of coefficients a and b can be found by minimizing the absolute value of error. Some study reveals that the minimum occurs if E l l I = - E l l 3 = E l l 2. Solving these equations yields -2L+2L¢1+( a°pt=

4f~+1

-2L) 2

( 4~ff--t- 1 - 2 L ) 2

'

bopt = aopt4~r~ -+- 1 / L .

(A24) (A25)

Coefficient c can be obtained by solving the equation El2 2 = - E 1 2 3. We obtain bopt(1 + 2L 2) - ( 2 L 2 ) / X / ~ + 1 +

c, =

4L 2 + 1 - L Z / ( L

2 + 1)

(A26)

A similar technique, involving E221, E222, E223 yields -2L2+

2LCL2+

(1/L5 + 4 - 212

eopt =

(A27) (¢~5 + 4 _ 212

dopt = eoptgt~ + 4.

(A28)

Another value of coefficient c can be found by solving the equation E213 = -E212. We obtain dopt(2 + L 2) - ( 2 L 2 ) / g t ~ +

C2=

L2 + 4 --LZ/(L 2 + 1)

1 + v~ (A29)

D.Coquin,Ph.Bolon~PatternRecognitionLetters16(1995)911-923

922 with A = (dopt(2 + L 2) and

A'=

(

bopt(1 + 2L 2)

)( 2L2,) (

(2L2)

~

2

-

L2 + 4 - L 2

-

L2

)(dZpt(L2+ L2)(

+-------~

(2L) 2 + 1

L2 + 1

1 ) - ( 2 L ) 2)

(A30)

b°2pt(L2+ 1 ) - (2L)2).

(A31)

It should be noticed that we obtain two different expressions for coefficient c (c 1 in Eq. (A26) and c 2 in Eq. (A29)). The effective value of c is chosen so that the maximum error is minimized. By studying this maximum error as a function of pixel width L, it can be shown that the optimal value is given by Eq. (A29). The maximum error, denoted E=aX, is then found by inserting (A27) into (A22). It is proportional to the radius R of the circular trajectory.

1 -2LZ+2LffLZ+(vI~+4-2)2 R (A32) If we consider a square grid (L = 1), we obtain a = e --- 0.9864, b = d ~ 2.2057, c 1 = C2 ~- 1.4079. (A33) These values are slightly different from those obtained by conducting the optimization on a vertical line (Borgefors, 1986): a = e -= 0.9859, b = d -= 2.2078, c I = c 2 -= 1.4081. (A34)

A p p e n d i x B. C o n s t r a i n e d coefficients

If we set e = 1 and a = L, the differences between the local distance and the Euclidean distance are given by Ell I = E222 = 0, Ell 2 = R 4 ~

+ 1

1

)

(B1) (B2)

= El21,

E113=R(~(b-2L)2+1-1), E122 = R

(c__ 1 ~+

(83)

)

(B4)

1 = E212,

E123=R( ~(b-c)2+L2(ic-b)2

--1)

L

EEn=R E213

1/~+4

)

(B6)

1 =E221,

= R ( ~(2c-d)2+(L(d-c))2L

E223R( ~(d-2)2+L2 L

)

(B5)

-1) ,

(B7)

(B8)

923

D. Coquin, Ph. Bolon / Pattern Recognition Letters 16 (1995) 911-923

The optimal values of coefficients b, c and d are obtained by minimizing the maximum error between the local distance transform and the Euclidean distance transform. From Eqs. (B2) and (B3), we obtain the value of coefficient b 2L(aL z + l ) - 2 bc opt =

4x/~+l 4L 2

+ ~1 (B9)

with A1

=

(4L z + 5)(4L 2 + 1) 2 - (4L z + 1) 3 + ( - 8 L ) ( 4 L z + 1) 4 f ~ +

1.

(B10)

The optimal value of coefficient c can be found by solving the equation E213 = - E 2 1 2 . We obtain Cc

de_opt(2 + L2) - ( 2 L 2 / 1 / ~ + 1 ) + ~ ( L 2 "1-4) -- L 2 / ( L 2 + 1)

opt =

(Bll)

with 2L 2 A2=

dc opt(2+L 2)

)2

~

(

-((L2+l)dZ-°P t-4L:)

L2

L2+4

L2+l -

-

).

(B12)

The optimal value of coefficient d is obtained by setting Ez23 = - E z l 1. We obtain dc opt= 2 with 13 ----"

~

+

/

1

L2 + 4

( 2L2)2 (L2) 2

~

- (4 - 3L 2) 1

Lz-~ 4 "

(B13)

(B14)

If the pixel width L is equal to 1 (square grid), these coefficients become a c = e c = 1,

bc = d c ~ 2.1943,

c c -= 1.4097.

(B15)

They differ form those obtained by Borgefors: a = e = 1,

b = d ~ 2.1969,

c --- 1.3946.

(B16)

References Bolon, Ph., J.L. Vila and T. Auzepy (1992). Op6rateur local de distance en maillage rectangulaire. Proc. 2~me CoUoque de Gdom~trie Discrete: Fondements et Applications, 45-56. Borgefors, G. (1986). Distance transformations in digital images. CVGIP 34, 344-371. Coquin, D. and Ph. Bolon (1993). Comparaison d'op6rateurs locaux de distance. Proc. 3~me Colloque de G~om~trie Discrete: Fondements et Applications, 182-191. Coquin, D. (1994). Op6rateur de distance en maillage reetangulaire. Internal report, I_AMII 94/03. Danielsson, P.E. (1980). Euclidean distance mapping. CGIP 14, 227-248 Montanari, U. (1968). A method for obtaining skeletons using a quasi-euclidean distance. J. ACM 15 (4), 600-624. Mullikin, J.C. (1992). The vector distance transform in two and three dimensions. CVGIP: Graphical Models and Image Processing 54 (6), 526-535. Rosenfeld, A. and J. Pfaltz (1966). Sequential operations in digital picture processing. J. ACM 13, 471-494. Rosenfeld, A. and J. Pflatz (1968). Distance functions on digital pictures. Pattern Recognition 1, 33-61. Thiel, E. and A. Montanvert (1992). Chamfer masks: discrete distance functions, geometrical properties and optimization. Proc. 11th IAPR Internat. Conf. on Pattern Recognition 3, 244-247. Verwer, B.H. (1991). Local distances for distance transformations in two and three dimensions. Pattern Recognition Lett. 12, 671-682.