Elsevier

Pattern Recognition Letters

Volume 28, Issue 15, 1 November 2007, Pages 2029-2036
Pattern Recognition Letters

Weighted distances based on neighbourhood sequences

https://doi.org/10.1016/j.patrec.2007.05.016Get rights and content

Abstract

By combining weighted distances and distances based on neighbourhood sequences, a new family of distance functions with potentially low rotational dependency is obtained. The basic theory for these distance functions, including functional form of the distance between two points, is presented. By minimizing an error function, the weights and neighbourhood sequence that give the distance function with the lowest rotational dependency are derived. To verify that the low rotational dependency of the proposed distance function is valid also in applications, the constrained distance transform on a binary image is computed and compared with some traditionally used distance functions.

Introduction

In (Rosenfeld and Pfaltz, 1966), the classical city-block and chessboard distances, defined as the shortest path between two grid points using only 4- and 8-neighbours respectively, are considered. In (Rosenfeld and Pfaltz, 1968), it is noted that the distance function obtained by mixing the city-block and chessboard distances is not as rotational dependent. These distances are called octagonal distances, since they generate octagonal shaped discs. There is another very common way of modifying the city-block and chessboard distances in order to obtain a less rotational dependent distance, the weighted distances (Montanari, 1968, Borgefors, 1984, Borgefors, 1986). With these distances, each local step is given a weight, which is considered when computing the distance, i.e., when finding the minimal cost path.

The distances obtained by mixing steps corresponding to 4- and 8-neighbours suggested in 1968 by Rosenfeld and Pfaltz (1968) are also called distances based on neighbourhood sequences (or octagonal distances, here denoted by n.s.-distances). The literature on n.s.-distances is rich; a theory for periodic n.s. not connected to any specific neighbourhood relations in Zn is presented in (Yamashita and Honda, 1984, Yamashita and Ibaraki, 1986) and further developed for the natural neighbourhood structure by the so-called octagonal distance in (Das and Chakrabarti, 1987, Das et al., 1987). Results for general (not necessarily periodic) n.s. are presented in (Fazekas et al., 2002, Nagy, 2003, Strand and Nagy, 2007).

Many approaches where the deviation from the Euclidean distance is minimized in order to find the optimal n.s. (n.s.-distances) or weights (weighted distances) have been proposed for Z2. In most papers, error functions minimizing the asymptotic maximum difference of a Euclidean ball and a ball obtained by using n.s.-distances (Yamashita and Ibaraki, 1986, Das, 1992, Das and Chatterji, 1990) or weighted distances (Borgefors, 1986, Verwer, 1991) are minimized. Other approaches have also been considered for n.s.-distances. In (Hajdu and Nagy, 2002), optimal neighbourhood sequences for the 2D hexagonal and triangular grids are found using a compactness ratio – the ratio between the squared perimeter and the area of the convex hull of the disks obtained by using neighbourhood sequences. In (Hajdu and Hajdu, 2004), the symmetric difference is used for n.s. in Z2 and in (Nagy and Strand, 2006), the following error functions are considered for n.s. in the face-centered cubic and the body-centered cubic grids: absolute error, relative error, compactness ratio, maximal inscribed ball, and minimal covering ball. In this paper, the compactness ratio is considered.

In this paper, the constrained distance transform (cDT) is computed using some distance functions. The image is divided into object pixels and obstacle pixels. The cDT labels each object pixels with the distance between the pixel and one or more source pixels, where paths defining the distance are not allowed to cross obstacle pixels. The constrained DT using path-based distance functions can be computed using standard shortest-path techniques for weighted graphs resulting in a linear time algorithm. In (Piper and Granum, 1987), the Dijkstra’s graph search algorithm is used. A bucket sorting implementation of the Dijkstra’s algorithm is used in (Verwer et al., 1989).

When the cDT is computed using the Euclidean distance function, only the pixels that are visible from the source pixel can be assigned the Euclidean distance in linear time. To assign the distance to the other pixels, a set of pixels defining discrete straight line segments (DSSs) not intersecting the obstacles are found such that the sum of lengths of the segments is the shortest constrained distance. Thus, the time complexity for algorithms computing cDT for the Euclidean distance depends on the number of obstacle pixels. In (Coeurjolly et al., 2004), a 2D-algorithm that runs in O(nm), where n is the number of object pixels and m is the number of obstacle pixels, is presented together with an approximate solution that runs in O(n log(m)). In the algorithm presented in (Ragnemalm, 1993), the DSSs is also updated only for visible pixels. In Section 6, the cDT for the proposed distance function is compared with some traditionally used distance functions including the Euclidean distance.

In this paper, we restrict the discussion to distances using the 3 × 3 neighbourhood with two weights. The distance function presented here uses n.s. to restrict some steps to the 4-neighbourhood. In conjunction to this, each step is weighted resulting in a less rotational dependent distance function. A functional form of the distance between two points is derived for both Z2 and R2. The latter is used in the optimization where the optimal (according to the error function) pair of n.s. and weights are derived. The theoretic results are evaluated by computing the constrained DT using some distance functions.

Section snippets

Basic notions

Two grid points p1=(x1,y1),p2=(x2,y2)Z2 are ρ-neighbours, ρ  {1, 2}, if|x1-x2|+|y1-y2|ρandmax{|x1-x2|,|y1-y2|}=1.The points p1, p2 are adjacent if p1 and p2 are ρ-neighbours for some ρ. Two ρ-neighbours such that equality holds for both equations in (1) are called strict ρ-neighbours. A n.s. B is a sequence B=(b(i))i=1, where each b(i) denotes a neighbourhood relation in Z2. If B is periodic, i.e., if for some fixed strictly positive lZ+, b(i) = b(i + l) is valid for all iZ+, then we write B = (b

Distance function in discrete space

We state now a functional form of the distance between two grid points (0, 0) and (x, y), where x  y  0. Observe that by translation-invariance and symmetry, the distance between any two grid points is given by the formula presented in Theorem 5. The following lemma is intuitively valid. Since it will be used in several proofs in this paper, it is proved for the completeness.

Lemma 4

Given a n.s. B and a point (x,y)Z2 such that x, y  0, there is a shortest B-path between 0 and (x, y) consisting of only the

Distance function in continuous space

For x  y  0, the following distance function is considered:dα,β(0,(x,y);γ)=(2k-x-y)·α+(x+y-k)·β,wherek=mink:kx+max(0,y-(1-γ)k),where x,y,kR and γR, 0  γ  1 is the fraction of the steps where 2-steps are not allowed (so 1Bk and 2Bk corresponds to γk and (1  γ)k, respectively). In this way we get a generalization of the distance function in discrete space Z2 valid for all points (x, y) where x  y  0 in continuous space R2. By consideringdα,β(0,(x,y);γ)=rthe points on a circle of constant radius are

Optimization

Using the vertices of the discs with the proposed distance function, we can derive the area (A) and perimeter (P) of the discs. This is used in the following error function:E=P2A14π-1,where P and A is the perimeter and area of a disc, respectively. The closed formula of E for arbitrary α, β, γ is lengthy and is therefore omitted. Using this error function, often denoted the compactness ratio, the optimal values of β and γ are computed for α = 1. The error function, which equals 0 only for Euclidean

Evaluation in discrete space

The value of γ represents the fraction of the n.s. with 1:s. Since this value is irrational, approximations are considered in applications. The approximations that are used in this section are of increasing complexity. The aim is to highlight the difference between the simple distances that weighted n.s. distances build on compared to the general case of weighted n.s.-distances presented in this paper and also to compare with the Euclidean distance. We consider B1 = (1), B2 = (2), B3 = (1, 2), B4 = (1, 2,

Conclusions

A new distance function, obtained by combining n.s.-distances and weighted distances, has been presented. The rotational dependency is significantly reduced by using this approach compared to using only n.s. or weights to define the distance function. The asymptotic shape of the digital disc is a 12-sided polygon. This polygon is regular and, thus, has minimal rotational dependency when using the optimal weights and n.s. derived in this paper. For n.s.-distances and weighted distances, the

References (24)

  • A. Rosenfeld et al.

    Distance functions on digital pictures

    Pattern Recognition

    (1968)
  • R. Strand et al.

    Distances based on neighbourhood sequences in non-standard three-dimensional grids

    Discr. Appl. Math.

    (2007)
  • Cited by (0)

    View full text