The t-Cost-m-neighbour distance in digital geometry

17
Journal of Geometry 0047-2468/91/020042-1751.50+0.20/0 Vol. 42 (1991) (c) 1991Birkh~user Verlag, Basel THE t-COST-m-NEIGHBOUR DISTANCE IN DIGITAL GEOMETRY Partha Pratim Das, Partha Pratim Chakrabarti and Biswa Nath Chatterji A generalized distance measure called t-Cost-m-Neighbour (tCmN) distance in n-D grid point space is presented. Its properties as a metric are examined. It is shown that m-neighbour [2] and t- cost [3] distances evolve as subclasses of tCmN. An efficient method for computing the tCmN distance value between a pair of points is discussed. i. INTRODUCTION In discrete geometry of Z n, where Z is the set of integers and n is the dimension of the space, the distance between any two points u, v 6 Z n is defined as the length of a shortest path connecting u to v in an appropriate underlying graph. For all distances defined in Z n, the underlying graph has Z n as the node set. Every distance definition implicity embeds an adjacency relation (which is often called the neighbourhood relation between the points of the grid point space) and a corresponding edge-cost (or elementary path length between neighbours) to completely define the weighted graph. For a large number of cases the adjacency and the cost are isotropic in all 2 n spatial directions and uniform over all points in Z n. Though there have been investigations on more relaxed definitions [4,6,9], the imposition of the constraints of isotropy and uniformity yield elegant yet rich classes of distances [1-4,7]. However most of these retricted attempts have tried to engineer either the

Transcript of The t-Cost-m-neighbour distance in digital geometry

Page 1: The t-Cost-m-neighbour distance in digital geometry

Journal of Geometry 0047-2468/91/020042-1751.50+0.20/0 Vol. 42 (1991) (c) 1991Birkh~user Verlag, Basel

THE t-COST-m-NEIGHBOUR DISTANCE IN DIGITAL GEOMETRY

Partha Pratim Das, Partha Pratim Chakrabarti and Biswa Nath Chatterji

A generalized distance measure called t-Cost-m-Neighbour (tCmN) distance in n-D grid point space is presented. Its properties as a metric are examined. It is shown that m-neighbour [2] and t- cost [3] distances evolve as subclasses of tCmN. An efficient method for computing the tCmN distance value between a pair of points is discussed.

i. INTRODUCTION

In discrete geometry of Z n, where Z is the set of integers and n

is the dimension of the space, the distance between any two

points u, v 6 Z n is defined as the length of a shortest path

connecting u to v in an appropriate underlying graph. For all

distances defined in Z n, the underlying graph has Z n as the node

set. Every distance definition implicity embeds an adjacency

relation (which is often called the neighbourhood relation

between the points of the grid point space) and a corresponding

edge-cost (or elementary path length between neighbours) to

completely define the weighted graph. For a large number of

cases the adjacency and the cost are isotropic in all 2 n spatial

directions and uniform over all points in Z n. Though there have

been investigations on more relaxed definitions [4,6,9], the

imposition of the constraints of isotropy and uniformity yield

elegant yet rich classes of distances [1-4,7]. However most of

these retricted attempts have tried to engineer either the

Page 2: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Das 43

neighbourhood while the cost is tied to unity [2,6-8] or the

cost parameter by keeping the neighbourhood to a physical maximum

[1,3]. For example, Das et al in [2] have characterized the m-

n in Z n. Under this definition of m- neighbour distance d m

neighbourhood, 1 ~ m ~ n, any two consecutive points

(hypervoxels) on a shortest path share a common hyperplane of

dimension at least (n-m) and have an associated arc-cost of

unity. Hence one can vary the parameter m to get n distinct

distance measures in n-D. Interestingly ~ generalizes the lower

dimensional metrics of [6-8] like Cityblock, Chessboard, Grid,

Lattice etc. In [3] Das et al define the t-cost distance D E over

Z n. Here two points are neighbours when they just share a

hyperplane (of any dimension). But the cost associated with every

neighbouring pair is non-unity and non-linear. It uses a cost

parameter t (t is an integer between 1 and n). If two

consecutive points on a shortest path is separated by a

hyperplane of dimension r, then the elementary path cost between

them is defined to be min(t, n-r). Again there are n distinct t- n cost distances with the property that D~ ~ d~ and D n ~ d~.

Such cost interpreted distances are also new to digital geometry

of n dimensions.

Attempts to vary both cost and neighbourhood simultaneously have

been reported primarily in 2-D. In [i] Borgefors considers

variable neighbourhood definitions and associates a unique real

cost value to the dimension of the separating hyperplane. Her

approach has produced interesting and useful results in 2-D. Yet

her formulation is difficult to be extended to n-D in a

generalized manner and often fails to express the distance

measures as closed form functions easily. Incorporation of both

cost and neighbourhood has been studied in the light of

position dependent cyclic neighbourhood definition by Yamashita

and Ibaraki [9]. However their treatment of distance measures is

too general and eventually fails to capture the beauty, elegance

and efficiency of several closed form expressionswhich exist. In

fact they need to solve an integer programming problem to compute

the distance (and the shortest path) between a pair of points.

Page 3: The t-Cost-m-neighbour distance in digital geometry

44 Chakrabarti, Chatterji and Das

In this paper we investigate into a class of distance functions

in n-D under isotropy and uniformity assumptions where two

separate parameters, t for cost and m for neighbourhood have been

considered. We call it the t-Cost-m-Neighbour distance (tCmN).

It has a closed functional form, well-defined shortest paths and

an associated path tracing algorithm. Interestingly tCmN

includes the t-cost [3] as well as the m-neighbour [2] distance

as special cases and offers (n-2) (n-3)/2 new distance functions

in n-D. After preliminary definitions in section 2, we present

the closed functional form of tCmN in section 3. Metricity and

other properties of the distance are discussed in section 4. In

section 5 we present an efficient algorithm for the computation

of the distance and in section 6 we prove the corresponding t/m

path definition. Section 7 concludes the paper.

2. NOTATION AND DEFINITIONS

Throughout this paper we restrict our attention to regular

tessellations of n-D space which are produced by n sets of

mutually orthogonal hyperplanes. The mathematical model for this

space will be Z n. We shall also require the following

definitions.

N : Set of natural numbers.

u : u = (u(1),u(2),...,u(n)) is an n-tuple.

A n : If A is any set, then A n = {u I u(i) E A, 1 < i < n}.

[']' ['J: Ceiling and Floor functions respectively. For x ~ R,

(i) [x],Lx j s Z, and (ii) x- 1 < Lxj <_ x _< Ix] < x + 1

The following properties of ceiling and floor are also used.

PROPERTY i: If x,y E R & x > y then Fxl > [Yl & Lxj >- LYJ-

PROPERTY 2: If x 6 R & a 6 Z then Fx+al=[xl+a & Lx+aj=LxJ+a.

PROPERTY 3: If x,y E R then max(rxl, [yT) = [max(x,y)l.

PROPERTY 4: If x,y,z c R & x + y > z then rxl + [Yl > Fzl �9

Page 4: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Das 45

fi : A mapping from Z n to P, fi : zn ---> P' 1 N i N n. For all u

6 Z n, we define fi(u) as the value of the i-th maximum component

in lu I . That is, if kl,k2,..,kn are n distinct indices, 1 ~ kj

n, 1 ~ j ~ n then lu(kl) I ~ lu(k2) I ~ Ju(k3) I ~ ...~ lu(kn) I and

fi(u) = lu(ki) I, 1 N i N n. By definition f0(u) = 0. We also

define hi(u ) = 2ISjSi Ifj (u) l, ~ u 6 Z n. Clearly, h0(u)= 0 and

hn(U)= ZISjSn lu(J) I"

Metric : A distance function d :Z n x Z n ---> R + U {0) is called a

metric if d is positive definite, symmetric and triangular.

Neb(t,m,n) : The neighbourhood of a point u s Z n. Any two points

u,v 6 Z n are called neighbours (i.e., they are adjacent in the

underlying graph) if and only if, ~ w, w s Neb(t,m,n) such that v

= u + w or u = v + w. In this paper, we use Neb(t,m,n) = {w I w s

(0,+i} n, hn(W ) < m}. With Neb, we associate a cost function 6 :

Neb ---> R + U {0}, where 6(w) is the incremental distance or aro

cost between neighbours separated by w. ~; w s Neb(t,n), 6(w) =

min(t , hn(W)). Note that (n - hn(W)) is the dimension of the

separating hyperplane. This definition, however, necessitates the

following restrictions on the ranges of t and m, that is, 1 _< t _<

n and 1 < m _< n.

~(u,v;t,m:n): ~ u,v e Z n, a sequence of distinct points ~: x 0

(=u), Xl, x2,...,xM(=v ) such that, (xi+ 1 - xi) ~ Neb(t,m,n),

0Si!M-1 is called a t/m-path from u to v. Length of the path is

defined as l~(u,v;t,m:n) I = ZOSi~M-I 6(Xi+l-Xi)" Generally there

are infinitely many paths from u to v. The shortest path from u

to v (also called minimal path) is denoted as ~*(u,v;t,m:n).

E n : The Euclidean distance in n-D.

: The m-neighbour distance function [2]

~ : zn x zn ---> P 1 S m S n, n r N.

~(u,v) = max(hl(U - v), ~n(U - v)/~), ~ u, v s Z n.

D~ : The t-cost distance function [3]

D~: Z n x Z n _4_> p, 1 S t S n, n E N

Page 5: The t-Cost-m-neighbour distance in digital geometry

46 Chakrabarti, Chatterji and Das

D~(U,V) = ht(u - v), ~ u, v E Z n.

n(u,v) and Clearly, dT(u,v ) = D n

d nn(u,v) = D~(u,v), ~ u, v 6 Z n.

3. t-COST-m-NEIGHBOUR DISTANCE

For all u,v e Z n, we define the t-Cost-m-Neighbour distance

(tCmN-distance, for short) d(u,v;t,m:n) between u and v as

"t d(u,v;t,m:n) = max Si(X), where x[i) = lu(i) - v(i) l l<_i_<n,

i=0

i F n = Z f.(x) + Iminimum(l,(t-i)/(m-i)) Z f~(x)| 0<i<t. Si(x) j=l 3 j=i+l ~ ' - -

and minimum(l, (t-i)/(m-i) )

= (t-i)/(m-i), if 0 ~< (t-i)/(m-i) < 1

-- i, if (t-i) > (m-i) and t,m,n 6 N.

Note that, by the definition of the minimum function Si(x ) is

defined for i = m, since, minimum(l,(t-i)/O) = I. Clearly for all

t,m ~ N and 0 ~ i ~ t, we have 0 ~ minimum(l, (t-i)/(m-i)) ~ I.

For the ease of notation we shall write simply d(u,v), d(t,m:n)

or d in place of d(u,v;t,m:n) whenever the missing arguments are

implicitly clear. We also write d(x) to mean d(0,x).

EXAMPLE i: Let n = 4, m = 3, t = 2, u = (-2,3,5,-4) and v =

(3,-2,7,-8). Hence x = (5,5,2,4) and

fl(x) = 5, f2(x) = 5, f3(x) = 4 and f4(x) = 2

+ [ f j c : ) ] : + [11 /2 ] = l l

S2(X) = fl (x) + f2(X) + 0 = 5 + 5 -- i0.

Therefore, d(u,v) = max(ll,ll,lO) = ii.

NOW consider the following sequence ~I of points as defined by

Neb(2,3,4) :

Page 6: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Das 47

=l -= (-2,3,5,-4)~-(-1,2,5,-5)5 ~-(0,1,5,-6) I 2 (i,0,5,-7)

(2,_1,6,_7) I 2 (2,-2,7,-8) I 1 (3,-2,7,-8).

i 2 i

Clearly ~i is a valid 2/3-path from u to v where I ~ denotes the

associated arc-cost and l~iI = ii = d. Thus ~i is a shortest

path from u to v. However the minimal path in digital geometry

may not be unique. For example, we have another path ~2 with

I~21 = ii as follows:

~2--- (-2,3,5,-4) 5-z-(-1,2,5,-5)I i (0,2,5,-5) I 2 (1,1,G,-5)

(1,0,7,-6) I 2 (2,-1,7,-7) ~--(3,-2,7,-8).

i 2 l

As a matter of fact that there are many paths with length = Ii

whereas

~3 = (-2,3,5,-4) ~2_ (-2,2,6,-4) J 1 (-1,2,6,-4)I 2 (-1,1,6,-5)

.' 2 (0,0,7,_5) I 1 (0,0,7,_6) I 2 (i,-i,7,-6) ~ 2- (2,-2,7,-7) .' 2

(3,-2,7,-8)

is a valid 2/3-path which is not minimal because I~31 = 14. A

little study of the neighbourhood will reveal that there does not

exist any 2/3-path between u and v with length < ii.

4. PROPERTIES OF tCmN

The most important property of a distance function is obviously

its metricity. In Theorem 1 we prove that tCmN is a metric.

However we need few related results as presented in Lemmas 1

through 3.

LEMMA I: For all n ~ N and x,y E Z n, 0 < i < n,

hi(x ) + hi(Y) > hi(x + y)

Proof: Follows immediately from the definition of hi, since lal +

Ib I >_ la + b I , ~ a,b ~ Z.

LEMMA 2: For all t,m,n c N, x ~ Z n and 0 < i < t.

Li(x ) = ((m-t)hi(x) + (t-i)hn(X))/(m-i), for t < m

Page 7: The t-Cost-m-neighbour distance in digital geometry

48 Chakrabarti, Chatterji and Das

= hn(X ) for t > m o_rr i > n.

i n where Li(x ) = j__Zlf j (x) + minimum(l, (t-i)/(m-i)) j=i+IZ f.] (x)

Proof: Immediate from the three cases: t<m, t~m and i~n.

Since Si(x ) = FLi(x)] , we can use simplified expressions for

Si(x ) if t ~ m or i ~ n. We show later that for all practical

purposes it is sufficient to consider only t < m. Hence the

above lemma helps to remove the 'minimum' function from the

definition of tCmN.

LEMMA 3: For all t, m, n ~ N and x, y E Z n

Si(x ) + Si(Y ) ~ Si(x + y), 0 S i ~ t.

Proof: First we prove that Li(x ) + Li(Y ) > Li(x + y), 0 < i < t.

Case i: t < m. From Lemma 2,

Li(x) + Li(Y) = ((m-t) (hi(x) + hi(Y))+(t-i) (hn(X)

+ hn(Y )))/(m-i)

> ((m-t)hi(x+y) + (t-i)hn(x+y))/(m-i) [Lemma i]

> Li(x+y), 0 < i < t.

Case 2: t ~ m or i Z n. similar to case 1.

Now the result follows from property (4) of ceiling function

since Si(x ) = FLi(x)l, 0 ~ i S t and x ~ Z n.

Now we present the metric property.

THEOREM i: For all t,m,n E N the t-Cost-m-Ne~ghbour distance is a

metric over Z n.

Proof: Positive definiteness and symmetry are obvious from the

definition. Triangularity follows from Lemma 3.

The above theorem suggests an infinite class of metrics in n-D,

each characterized by some t,m 6 N. However, in reality, there

exist only finitely many distinct tCmN-distance functions.

Page 8: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Das 49

EXAMPLE 2: Let n = 7 and x = (8,7,6,6,5,4,4). Various tCmN

distance values for t ~ 1 and m ~ 1 are shown in Table i. We

find that there are only 22 distinct functions in 7-D of which

only i0 are new.

Table i: tCmN-distance for n = 7 and x = (8,7,6,6,5,4,4). Entries are d(x:t,m;7

tim 1 2 3 4 5 6 7 8

i 40 40 40 40 40 40 40 40

2

20 40 40 40 40 40 40 40

3 4

14 i0 27 20 40 30 40 40 40 40 40 40 40 40 40 40

�9 t,m ~ 1

5 6 08 08 16 15 24 22 32 28 40 34 40 40 40 40 40 40

7 8 08 08 15 15 21 21 27 27 32 32 36 36 40 40 40 40

9 o o o

08 ... 15 ... 21 ... 27 ... 32 ... 36 ... 40 ... 40 ...

We prove the above observations in Lemma 4 and estimate the

number of such distinct forms in Lemma 5.

LEMMA 4: For all n r N and x c Z n,

d(x;t,m:n) = ~(x), if t = 1 and m > 1

= d~(x) = Dn(x), if t > m, o_rr n < t < m

= DE(x), if t < n < m.

Proof: We consider four cases for the proof.

Case I: m < t

Therefore, minimum(l, (t-i)/(m-i)) = I, 0 < i < t.

Hence, Si(x) = [Li(x)] = [hi(x) + (hn(X) - hi(x))], 0 _< i < t

= h n (x)

Clearly, d(x;t,m:n) = hn(X) = ~'l<j<n Ix(j)l = d~(x) = Dn(x)

Case 2: n < t < m

Therefore, Li(x ) = hn(X ), n < i < t

Next we show that Li(x ) _< hn(X), 0 < i _< n

i.e., hi(x ) + ((t-i)(hn(X) -hi(x)))/(m-i) < hn(X)

i.e., (m - i + t + i) (hi(x) - hn(X)) < 0

i.e., (m - t) (h n(x) - h i(x)) > 0

Page 9: The t-Cost-m-neighbour distance in digital geometry

50 Chakrabarti, Chatterji and Das

which trivially holds since 0 < i < n.

Hence, d(x;t,m:n) = ~max0<i< t Li(x)1 = hn(X ) = d~(x) = Dn(x)

Case 3: t _< n < m and t ~ m

In this case, Li(x ) < ht(x), 0 < i < t. To prove this, it is

required to show that,

hi(x) + ((t-i) (hn(X) -hi(x)))/(m-i ) < ht(x )

i.e., (m-t)hi(x) < i(hn(X )-ht(x ))+(m-t)ht(x ) - t(hn(X )-ht(x ))

i.e., (t-i) (hn(X) - ht(x)) _< (m-t) (ht(x) - hi(x))

since, m > n, it is sufficient to prove that,

(t-i) (hn(X) - ht(x )) < (n-t) (ht(x) - hi(x ))

i.e., (t-i)Tt+l<j< n fj(x) < (n-t)Zi+l<j< t fi(x)

Since, fi(x) > ft(x) > fn(X), it is sufficient to prove that,

(t-i)Zt+l<j_< nft (x) < (n-t)~.i+l<j< t ft(x)

i.e., (t-i)(n-t)ft(x) < (n-t)(t-i)ft(x) which always holds.

Again, Lt(x ) = ht(x ).

Hence, d(x;t,m:n)= Fmt~.= Li(x)l= [Lt(x)1= ht(x)= DE(x ) , l<t_<n.

Case 4: t = I.

S0(x ) = 0 + Fminimum(l,i/m)hn(X)1 = [ ZISjS n Ix(j)I/m l

Sl(X) = hl(X ) + 0 = maxl_j<~<__n Ix(j)l

Therefore, d(x;t,m:n)= max(S0(x),Sl(X)) = ~(x).

From [2], ~(x) = d~(x), for x e Z n and m ~ n. So, in this case

also there are only n distinct forms possible.

Hence the class of tCmN-distances truly generalizes the m-

neighbour and as well as t-cost distances in n-D.

Combining all cases of Lemma 4, we also find that all possible

values of m and t do not produce distinct functions and it is

sufficient to consider only distances defined by 1 S t S m S n.

The number of such distinct forms is given in the following

lemma.

LEMMA 5: For all n ~ N, the number of distinct tCmN-distances is

Page 10: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Das 51

(n2-n+2)/2.

Proof: From the previous lemma, it is easy to see that d(t,m:n)'s

are distinct for l~t<mSn. The number of such distance functions

is Z2SmS n ZIStSm-I 1 =ZISmSn-I m =n(n-l)/2.

Also from Lemma 4, we get that there exists only one more

distinct form of d(t,m:n), that is for t = m, which is equal to

d~. Hence the total number of distance functions = (n2-n+2)/2 of

which (n2-n+2)/2 - (2n-2) = (n-2) (n-3)/2 are new. The above two

lemmas justify the observations from Table I. Since there is no

new metric in 2- or 3- D, lower dimensional researches earlier

had enough reasons to miss the tCmN form altogether.

We know that in 2-D the cityblock distance is always greater than

or equal to the chessboard distance between the same pair of

points. A similar ordering exists between m-neighbour distances

[2] and t-cost distances [3] in Z n. The following lemma proves a

generalization.

LEMMA 6: For all x ~ Z n, 1 ~ t S m S n.

(a) d(X;tl,m:n) Z d(x;t2,m:n) iff t I ~ t2, and

(b) d(x;t,ml:n ) ~ d(x;t,m2:n ) iff m I ~ m 2.

Proof: Part (a): Sufficiency is trivial. To prove the necessity,

let ~ x ~ Z n, d(X;tl,m:n ) Z d(x;t2,m:n ) but t I < t 2. Clearly ~ u

Z n such that d(U;tl,m:n ) ~ d(u;t2,m:n ) since t I ~ t 2. But from

the forward direction of the proof, t I < t 2 implies d(U;tl,m:n ) <

d(u;t2,m:n ). Contradiction. Hence t I ~ t 2.

Part (b): Similar to Part(a).

The above property is evident in Table i, where distance values

decrease along every low and increase along every column. Since

the change in d(t,m,n) is monotonic with respect to both t and m

we can engineer these parameters simultaneously to obtain a new

metric which approximates the real Euclidean distance better than

the previously known metrics. However this problem of optimal

Page 11: The t-Cost-m-neighbour distance in digital geometry

52 Chakrabarti, Chatterji and Das

parameter selection will not be taken up in this paper.

5. EFFICIENT COMPUTATION OF d(t,m;n)

In this section we present an efficient algorithm to compute

d(t,m:n). The idea is to design an algorithm to calculate some

kl, 0 ~ kl S t such that Lkl ~ Li, 0 ~ i ~ t without explicitly

computing the values of Li's. If such a kl can be formed then d =

F Lkl ql. In this regard we first observe some ordering amongst

Li(x)'s.

THEOREM 2: For all n s N, 1 ~ t < m ~ n and x 6 Z n,

(a) if Li(x ) < Li+l(X ) then Li_l(X) < Li(x ) and

(b) if Li(x ) < Li_l(X ) then Li+l(X) < Li(x), 0 < i < t.

Proof: Part (a): Let Li(x ) < Li+l(X ) .

Or, ((m-t)hi(x)+(t-i)hn(X))/(m-i) <

((m-t)hi+l(X)+(t-i-l)hn(X))/(m-i-1) [Lemma 2]

Simplifying, hn(X ) < (m-i)fi+l(X) + hi(x ) (5.1)

We need to prove, Li_l(X ) < Li(x )

That is, hn(X ) < (m-i+l)fi(x) + hi_l(X) [from (5.1)]

Now, (m-i+l) fi (x) +hi_l (x) = (m-i) fi (x) +hi (x) _> (m-i) fi+l (x) +

hi(x ) > hn(X ) [from (5.1)], since fi(x) > fi+l(X)]. Hence Li_l(X)

< L i (x)

Part (b): Similar to part (a).

DEFINITION: For x s Z n, we define two integers kl and k2 as:

i. kl is the largest index for which Lkl_l(X ) < Lkl(X). Formally,

Li_l(X) < Li(x), 0 S i S kl S t and Lkl(X) { Lkl+l(X).

2. k2 is the smallest index for which Lk2+l(X)< Lk2(X). Formally,

Li+l(x) < Li(x), 0 S k2 ~ i S t and Lk2(X) { Lk2_l(X).

Then next lemma follows from the definitions.

LEMMA 7: For all x c Z n,

Page 12: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Des 53

(a) 0 < kl < k2 <_ t

(b) Lkl(X) = Li(x) = Lk2(X), kl < i < k2.

Proof: Part (a): Assume the converse, kl > k2. Choose some i,

k2 ~ i < kl. By the definition of k2, Li+l(X ) < Li(x ) and by the

definition of kl, Li(x ) < Li+l(X ). Contradiction. Hence, kl S k2.

Part ~b): Note that if kl = k2 then the result is trivial.

Therefore assume kl < k2. We first show that, Lkl(X ) = Lkl+l(X ) .

If possible, let Lkl(X ) ~ Lkl+l(X). Hence from defintion of kl,

Lkl(X ) > Lkl+l(X). Therefore, from part (b) of Theorem 2,

Lkl(X) > Lkl+l(X) > nkl+2(x) >...> Lk2_l(X) > Lk2(X).

But, by the definition of k2, Lk2_l(X ) ~ Lk2(X). Contradiction.

Hence Lkl(X) = Lkl+l(X)-

Next we show that Lkl+l(X ) = Lkl+2(x ) . Again, assume the

converse, Lkl+l(X ) ~ Lkl+2(x). Thus two cases are possible here.

Case i: Lkl+l(X ) > Lkl+2(x). Then again as in the first part of

the proof we reach a contradition.

Case 2: Lkl+l(X ) < Lkl+2(x ). Therefore by part(a) of Theorem 2,

Lkl(X ) < Lkl+l(X ) . Contradiction. Hence Lkl+l(X ) = Lkl+2(x ) .

Repeating the same logic we get, Lkl(X) = Lkl+l(X ) = Lkl+2(x )

=...= Lk2_l(X ) = Lk2(X ) .

Now it is trivial to see that d(x) can be directly computed if we

know kl or k2, because, d(x)= ILkl(X)l = ILk2(X)l. The following

lemma provides a straightforward algorithm for computing kl (or

k2) from the definition.

LEMMA 8: For all x ~ Z n,

kl = rain {ilLi(x)#Li+l(X )) = rain (ilhn(X)~(m-i)fi+l(X)+hi(x)) 0~i<t 0Si<t

k2 = max . . . ._ . .~ilLi(x~%Li-l(X~ ) = max . . . . . . . . . .~ilhn(X~(m-i~fi(x~+hi(x~ ). 0Si<t 0~i<t

An example, showing the determination of kl and k2 is given in

Table 2. A diagramatic exposition of the same is presented in

Figure i.

Page 13: The t-Cost-m-neighbour distance in digital geometry

54 Chakrabarti, Chatterji and Das

Table 2: Determination of kl and k2 for n=20, m=14, t=12 & x=(i0,8,8,6,5,4,4,4,4,3,3,3,2,2,2,2,1,I,I,0). We get kl = 5, k2 = 9 and d(x) = 65. (see Lemma 8 & Figure i). [For brevity of form we write fi as f.i, fi+l as f.(i+l) etc. in the table]

i 0 1 2 3 4 5 6 7 8 9 f.i 0 i0 8 8 6 5 4 4 4 4 h.i 0 i0 18 26 32 37 41 45 49 53

(m-i)f.(i+l)+h.i 140 114 114 92 82 73 73 73 73 68 (m-i)f.i+h.i - 140 114 114 92 82 73 73 73 73

4 63~ 64 5 64{ 65 65 65 65 65 L. i 62~ 63~

S.i 63 64 64 65 65 65 65 65 65 65

i f.i h.i

(m-i) f. (i+l) +h.i (m-i) f. i+h. i

L.i

S.i

i0 ii 12 13 14 15 16 17 18 19 20 3 3 3 2 2 2 2 1 1 1 0

56 59 62 64 66 68 70 71 72 73 73 68 68 . . . . . . . . . 68 68 . . . . . . . . .

65 64 62 . . . . . . . .

65

6~

j 63

. . - ~

ff l

62

61

Si (x) I l '

0 2 3

ki=5

4 5 6 7 8 [ -----~

~, -~'d (x) k2= 9

I I I

t 42 I

9 10 11 12

Figure 1: Determination of kl and k2. The solid line shows S i and the dotted lines show Li's. (See Table 2 for data)

Page 14: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Das 55

Quite interestingly, neither condition of determining kl or k2

involves the cost parameter t. It only determines the range of i

over which the search for kl or k2 is to be performed. In a

degenerate case, however, there may not exist any kl in the range

0 ~ kl < t, that is, hn(X ) < (m-t+l)ft(x) + ht_l(X ) . Or, hn(X ) <

(m-t) ft(x) + ht(x ) . Then clearly kl = t. Similarly, if hn(X ) >

(m-l)fl(x) + hl(X), or hn(X ) > mfl(x), we can set k2 = 0.

Examples of such degenerate cases are shown in Tables 3, and 4

and in Figures 2 and 3 respectively.

Table 3: A degenerate case for kl (see Figure 2). n = 6, m = 5, t = 4, x = (7,6,5,5,2,2) & d(x i = 23

i 0 1 2 3 4 5 6 f.i 0 7 6 5 5 2 2 h.i 0 7 13 18 23 25 27

(m-i) f. (i+l)+h.i 35 31 28 28 -- -- - (m-i) f. i+h. i -- 35 31 28 28 -- --

S.i 22 22 23 23 23 -- --

Note: kl = t = 4, k2 = 4 and f5 + f6 < f4 or h n < (m-t) f t + h t

Table 4: A degenerate case for k2 (see Figure 3) n = 7, m = 5, t = 4, x = (5,5,4,4,4,3,1) & d(x)= 21

i 0 1 2 3 4 5 6 7 f.i 0 5 5 4 4 4 3 1 h.i 0 5 i0 14 18 22 25 26

(m-i) f. (i+l) +h.i 25 25 22 22 . . . . (m-i) f. i+h. i - 25 25 22 22 -- - -

L.i 204 203 202 20 18 -- -- --

S.i 21 21 21 20 18 -- -- --

Note: kl = 0, k2 = 0 and h 7 > 5f I or h n > mf I.

Now we can summarize the above results into an efficient

algorithm to compute d(u,v) in o(nlog2n ) time (which is dominated

by the sorting time in step 0). The algorithm uses the definition

of kl. (It may also be written using k2). We have used this

algorithm to construct Table i.

Algorithm d(u,v,t,m,n);

Step O: Form difference vector x = lu-vl. Sort x to compute fi(x), ~i, 1 S i S n Set r <--- hn(X); /* That is, r <--- ZiX i */

Page 15: The t-Cost-m-neighbour distance in digital geometry

56 Chakrabarti, Chatterji and Das

Step i:

Step 2:

i <--- 0; s <--- mfl(x);

while {r<s) and ~i<t-l) do /* This loop computes kl [z <--- l+l; using Lemma 8 */ s <--- s - (m-i) (fi(x)-fi+l(X)))

Step 3: if r~s then kl <--- i else kl <--- t /* This is the

degenerate case */

Step 4: d <--- ILkl(X)l /* The distance value is computed using Theorem 2 and Lemma 7 */

End-of-d.

23

~~22 ._J

2.1

k1=k2=4

r I I I

�9 I I

i I 0 1 2 3

L __,._

I

I i

I i I

I I ~ - - t = 4 I I

4

- , - - d ( x ) .~ 20

_.J

19

21 /k~=k~=0

I 1 I

I

I I f

I I I

0 2

-~-d(~)

SL(~)

--t--4

Figure 2: A degenerate case for kl (Table 3)

Figure 3: A degenerate case for k2 (Table 4)

6. PATH INTERPRETATION FOR t-COST-m-NEIGHBOUR DISTANCE

As mentioned in section i, every distance function in the digital

geometry has a natural shortest path interpretation on the

underlying weighted graph. Examples of such path definitions can

be found in [2-4,6-9]. In the present context tCmN also has a

path interpretation in minimal t/m-paths defined in section 2. To

put it precisely, the tCmN distance between any two point s in Z n

is equal to the length of the minimal t/m-path between them.

Hence the theorem.

THEOREM 3: For all u,v E Z n, d(u,v;t,m:n) = I~*(u,v;t,m:n) l.

Page 16: The t-Cost-m-neighbour distance in digital geometry

Chakrabarti, Chatterji and Das 57

We have already observed this property in Example I. We also

note that unlike the Euclidean geometry, minimal path in digital

geometry may be non-unique. Hence the proof of the correspon-

dence between minimal path length and distance value needs the

formulation of a minimal-path tracing algorithm whose complexity

reflects the distance between the points. The proof then follows

from the correctness of the algarithm. Such techniques have been

used at a number of places [2-5]. The details in this case can be

easily derived in a similar fashion. They are also given in [4].

The above theorem can be used to give an alternative proof of

Lemma 4 (the special cases of tCmN-distance). Because from the

definitions of Neb and t/m-path we get: (i) t/m-paths for m ~ n

are identical to t/n-paths. Clearly t/n-paths are same as t-paths

of [3]. Hence d(t,m:n) = DE, m ~ n. (2) 1/m-paths are precisely

the O(m)-paths of [2]. Hence d(l,m:n) = 4"

7. CONCLUSION

The study of t-Cost-m-Neighbour distance brings under one unified

framewozk a whole class of distances which can be defined in

digital geometry. The choices of the dimension n, the neighbour-

hood m and cost parameter t provide a range of distance functions

from simple chessboard, ~ityblock, grid, lattice distances to

complete classes like m-neighbour and t-cost distances in n-D.

The study of the hypersphere of tCmN and the approximation of the

Euclidean distance offer immediate challenges in this regard.

REFERENCES

[i] BORGEFORS, G. : Distance Transformations in Arbitrary Dimensions. Computer vision, Graphics and Image Processing 2__7 (1984), 333

[2] DAS, P.P., CHAKRABARTI, P.P. and CHATTERJI , B.N.: Generalised Distances in Digital Geometry. Information Sciences 422 (1987), 51-67

[3] DAS, P.P., MUKHERJEE, J. and CHATTERJI, B.N.: The t-Cost Distances in Digital Geometry, Information Sciences (1991),

Page 17: The t-Cost-m-neighbour distance in digital geometry

58 Chakrabarti, Chatterji and Das

to appear

[4] DAS, P.P.: Some Studies on Paths and Distances in Digital Geometry. Ph. D. Thesis, Department of E & ECE, Indian Institute of Technology, Kharagpur, India 1988

[5] ROSENFELD, A. and PFALTZ, J.L.: Sequential Operations in Digital Picture Processing. Journal of ACM 1_/3 (1966), 471- 494

[6] ROSENFELD, A. and PFALTZ, J.L.: Distance Functions on Digital Pictures. Pattern Recognition ! (1968), 33-61

[7] ROSENFELD, A.: Digital Geometry, in Picture Languages, Academic Press-New York 1979

[8] ROSENFELD, A.: Three Dimensional Digital Topology. Information and Control 5_O0 (1981), 119-127

[9] YAMASHITA, M. and IBARAKI, T.: Distances Defined by Neighbourhood Sequences. Pattern Recognition I_99 (1986), 237- 246

Department of Computer Science and Engineering, and Department of Electronics & Electrical Communication Engineering, Indian Institute of Technology, Kharagpur 721302, INDIA.

(Eingegangen am 18. Oktober 1989)

(Rev id ie r te Form am 8. Ju l i 1991)