scieee AI-readable full text Open interactive document viewer

Path-Based Distance Functions in n-Dimensional Generalizations of the Face- and Body-Centered Cubic Grids

Strand, Robin; Nagy, Benedek

Full text

Path-Based Distance Functions in n-Dimensional Generalizations of the Face- and Body-Centered Cubic Grids Robin Strand aand Benedek Nagy b aCentre for Image Analysis, Uppsala University, PO Box 337, SE-75105 Uppsala, Sweden bDepartment of Computer Science, Faculty of Informatics, University of Debrecen, PO Box 12, 4010, Debrecen, Hungary Abstract Path-based distance functions are defined on n-dimensional generalizations of the face-centered cubic and body-centered cubic grids. The distance functions use both weights and neighborhood sequences. These distances share many properties with traditional path-based distance functions, such as the city-block distance, but are less rotational dependent. For the three-dimensional case, we introduce four different error functions which are used to find the optimal weights and neighborhood sequences that can be used to define the distance functions with low rotational dependency. 1 Introduction By adding a grid point in the center of each cube with vertices on grid points in a cubic grid, a body-centered cubic (bcc) grid is obtained. The face-centered cubic (fcc) is obtained by instead adding a grid point at the center of each face of the cubes. When using non-standard grids such as the fcc and bcc grids for 3D images, less samples are needed to obtain the same representation/reconstruction quality compared to the cubic grid [1]. This is one reason for the increasing interest in using these grids in, e.g., image acquisition [1], image processing [2–4], and visualization [5,6]. See also [7]. Email addresses: [email protected] (Robin Strand), [email protected] (Benedek Nagy). Preprint submitted to Elsevier Science 3 February 2009 Optimal sampling in the sense of the Shannon sampling theorem is obtained when the reciprocal of a dense grid is used for representing the image. In this way, a sparse as possible grid is used for image representation [7]. The fcc grid is the densest three-dimensional point-lattice [8] and its reciprocal is the bcc grid. In number theory [8], the fcc grid is usually denoted D3and is a special case of the point-lattice Dn, here refered to as the n-dimensional fcc grid. The reciprocal of this point-lattice is D∗ n, here called the n-dimensional bcc grid. The n-dimensional fcc grid is the densest point-lattice in three, four, and five dimensions [8]. Thus, the n-dimensional fcc and bcc grids are potentially important for high-dimensional image processing. The 3-dimensional fcc and bcc grids can, e.g., be used when reconstructing, e.g., images from computed tomography with increased accuracy, see [1,7]. The results in this paper can be used to find appropriate distance functions for processing such images. Measuring distances on digital grids is of great importance both in theory and in many applications. Because of its low rotational dependency, the Euclidean distance is often used as distance function. Even though the rotational dependency is higher, there are many reasons to use distances defined as minimal cost-paths instead. In some aspects, distance functions defined by minimal cost-paths fits the digital geometry-approach better, [9]. For example, the set of the points of the digital plane (square grid) having Euclidean distance, e.g., 9 from a point consists of four points far from each other. Instead, digital circles using some path-based distances (for instance, distances based on neighborhood sequences) are sets of consecutive neighbor points. Another aspect is that when minimal cost-paths are computed, a distance function defined as the minimal cost path between any two points is better suited, see, e.g., [10], where the constrained distance transform is computed using the Euclidean distance. The resulting algorithm is complex since distances can be propagated only to “visible points”. The computational complexity (w.r.t. both time and space) of this algorithm is larger than the corresponding algorithm using a path-based approach which is simple, fast, and easy to generalize to higher dimensions [11,12]. We conclude that path-based digital distances are important both from a theoretical point of view and for several applications. Examples of path-based distances are weighted distances, where weights define the cost (distance) between neighboring grid points [2,3,13], and distances based on neighborhood sequences, where the cost is fixed but the adjacency relation is allowed to vary along the path [4,14]. These path-based distance functions are generalizations of the well-known city-block and chessboard distance function defined for the square grid in [15]. We will abbreviate neighborhood sequence with ns, distance based on neighborhood sequences with ns-distances, and weighted distances based on neighborhood sequences with weighted ns-distances or just wns-distances. Many approaches where the deviation from the Euclidean distance is mini- 2 mized in order to find the optimal ns (ns-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 ns-distances [16–19] or weighted distances [3,13,20] are minimized. Other approaches have also been considered for ns-distances. In [21], optimal ns 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 ns. In [22], the symmetric difference is used for ns in Z2and in [23], the following error functions are considered for ns on the fcc and the bcc grids: absolute error, relative error, compactness ratio, maximal inscribed ball, and minimal covering ball. In [16], a general definition allowing both weights and ns was presented. The full potential of using both weights and ns was discovered in [24], where ns and weights were together used in the sense of [16], but with the well-known natural neighborhood structure of Z2. In [24], the basic theory for weighted ns-distances on the square grid is presented including a formula for the distance between two points, conditions for metricity, optimal parameter calculation, and an algorithm to compute the distance transform. In [25], some basic theoretical results for weighted ns-distances on the fcc and bcc grids were presented. The theory for weighted ns-distances on the fcc and bcc grids was further developed in [26] by presenting sufficient conditions for metricity and algorithms that can be used to compute the distance transform and a minimal cost-path between two points. In [27] the theory for weighted distances based on neighborhood sequences with two neighborhood relations for the general case of point-lattices is considered. The asymptotic error using the compactness ratio was used to find the optimal weights and ns for weighted ns-distances on the fcc and bcc grids in [25]. The basic analysis presented in [25] is extended in [28] by considering the relative error, the compactness ratio, the maximal inscribed ball, and the minimal covering ball. As in, e.g., [3,13,16–18,20], the digital ball is compared with the Euclidean ball to get a measure of rotational dependency of a digital distance. Also, we analyze the behavior when ns of finite length, i.e., periodic ns is used. Note that the results presented here also applies to weighted distances and ns-distances, since they are both special cases of the proposed distance function. The distance function proposed here is used to find optimal weights for the weighted distance and optimal ns for ns-distances. It follows that the rotational dependency for the weighted ns-distance is less than or equal to both the weighted distance and the ns-distance. When the paper [28] was presented at the 12th international workshop on combinatorial image analysis (IWCIA 2008), there were several questions and comments about n-dimensional generalizations of the fcc and bcc grids. Therefore, in this paper, some results are extended to higher dimensions. 3 This paper consists of two parts. First, we define weighted ns-distances in the n-dimensional fcc and bcc grids by applying the theoretical framework presented in [27] to these grids. Formulas for point-to-point distance and conditions for metricity are presented. We also present the optimal parameter computations for the 3D fcc and bcc grids from [28]. 2 Distance Functions and Grids We will now give definitions of n-dimensional generalizations of the fcc and bcc grids. Using some previous results, we will also define the ns-distance and the weighted ns-distance for these grids. Let the set N1={v1,v2,...,vM} define the 1-neighbors of the point 0in a point-lattice G. Let also N2= {u1,u2,...,uN}define the strict 2-neighbors. We denote the set of 2-neighbors by N1,2=N1∪N2. A ns Bis a sequence B= (b(i))∞ i=1, where each b(i) denotes a neighborhood relation in G. If Bis periodic, i.e., if for some fixed strictly positive l∈Z+, b(i) = b(i+l) is valid for all i∈Z+, then we write B= (b(1), b(2),...,b(l)). A path, denoted P, in a grid is a sequence p0,p1,...,pnof adjacent grid points. A path is a B-path of length nif, for all i∈ {1,2,...,n},pi−1and piare b(i)-neighbors. The notation 1- and (strict) 2-steps will be used for a step to a 1-neighbor and step to a (strict) 2-neighbor, respectively. Definition 1 Given the ns B, the ns-distance d(p0,pn;B)between the points p0and pnis the length of (one of) the shortest B-path(s) between the points. Let the real numbers αand β(the weights) and a path Pof length n, where exactly l(l≤n) adjacent grid points in the path are strict 2-neighbors, be given. The length of the (α, β)-weighted B-path Pis (n−l)α+lβ. The B- path Pbetween the points p0and pnis a minimal cost (α, β)-weighted B-path between the points p0and pnif no other (α, β)-weighted B-path between the points is shorter than the length of the (α, β)-weighted B-path P. Definition 2 Given the ns Band the weights α, β, the weighted ns-distance dα,β(p0,pn;B)is the length of (one of) the minimal cost (α, β)-weighted B- path(s) between the points. The following notation is used: 1k B=|{i:b(i) = 1,1≤i≤k}| and 2k B=|{i:b(i) = 2,1≤i≤k}|. We associate with the sets N1and N1,2the chamfer masks C1={(vi,1)}M i=1 and C2=C1∪{(ui,1)}N i=1. The vectors in N1and N1,2are associated with 4 weight 1, and the chamfer masks are thus nothing but unit weighted vectors. AG-basis wedge of any chamfer mask C(Ccould be, e.g., either C1or C2) is a set of nlinearly independent vectors vi1,vi1,...,vinfrom Csuch that •vi1,vi1,...,vinis a basis of Gand •no vector of Cexcept vi1,vi1,...,vincan be written as a linear combination with positive (not necesarily integer-valued) coefficients of these vectors. See [3] for details. Each wedge defines a polytope by the convex hull of 0and the points 0+vij. With unit weights, the polytope BCof a chamfer mask C, [3], is the union of the polytopes of the wedges. Definition 3 A chamfer mask with unit weights is restricted (see [3]) if (symmetry) (v, ω)∈C=⇒(−v, ω)∈C(1) (Organized in G-basis-wedges)∀p∈G,∃W of Csuch that p∈ W and Wis a G-basis-wedge. (2) (Convex normalized polytope)BC= conv(BC).(3) Definition 4 A grid Gis wedge-2-generated by N1and N2if N1and N2are such that •C1={(vi,1)}M i=1 and C2=C1∪{(wi,1)}N i=1 are restricted Chamfer masks, • ∀i, ∃j, k :wi=vj+vk, and •each G-basis-wedge of N1is the union of some G-basis-wedges of N1,2. In [27], the ns-distance and the weighted ns-distance were presented for an arbitrary point-lattice Gwedge-2-generated by N1and N2. Let dC1be the distance function obtained by using the Chamfer mask C1and dC2be the distance function obtained by using the Chamfer mask C2. In other words, for any points p,q∈G,dC1(p,q) is the length of the shortest path between p and qusing only local steps from N1and dC2(p,q) is the length of the shortest path between pand qusing local steps from N1,2. The following theorems are proved in [27]. Theorem 5 (ns-distance in Gwedge-2-generated by N1and N2)Let G wedge-2-generated by N1and N2, the neighborhood sequence Band the points p,q∈Gbe given. Then d(p,q;B) = min nkk≥max ndC2(p,q), dC1(p,q)−2k Boo. When the square grid is considered and dC2is the chessboard distance and dC1is the city-block distance, the ns-distance is less than (or equal to) the city-block distance and greater than (or equal to) the chessboard distance. 5 Theorem 5 says that by replacing pairs of 1-steps from dC1with as many 2-steps as the sequence allows, the ns-distance is obtained. Remark 6 We will consider weights αand βas real numbers αand βsuch that 0< α ≤β≤2α. This is natural since •a2-step should be more expensive than a 1-step since strict 2-neighbors are intuitively at a larger distance than 1-neighbors (projection property) and •two 1-steps should be more expensive than a 2-step – otherwise no 2-steps would be used in a minimal cost-path. In the following theorem, the 1-steps are weighted with αand the 2-steps are weighted with β. A formal proof is found in [27]. Theorem 7 (Weighted ns-distance in Gwedge-2-generated by N1and N2) Let Gwedge-2-generated by N1and N2, the ns B, the weights α,βsuch that 0< α ≤β≤2α, and the points p,q∈Gbe given. Then dα,β(p,q;B) = (2d(p,q;B)−dC1(p,q)) α+ (dC1(p,q)−d(p,q;B)) β. We will now define n-dimensional generalizations of the fcc and bcc grids and apply Theorem 5 and 7 to these grids. 2.1 The n-dimensional fcc grid We use the following definition of the n-dimensional fcc grid for n≥3: Fn={p∈Zn:x1+x2+...+xn≡0 (mod 2)} together with the straight-forward generalization of the neighborhoods in the three-dimensional grid Fused in, e.g., [4,25,26,28], to get the natural neighborhoods N1and N2for Fn: N1=nv= (v1, v2,...,vn)∈Fn: max {|vi|} = 1 and X|vi|= 2o N2=nv= (v1, v2,...,vn)∈Fn: max {|vi|} = 2 and X|vi|= 2o. The following lemma gives a sufficient and necessary condition for a set of vectors in Fnto be a basis of Fn. Lemma 8 A set F={v1,v2,...,vn}of vectors in Fnis a basis of Fniff det (v1,v2,...,vn) = ±2 6 The proof of Lemma 8 is technical and is therefore omitted. The lemma can be proved analogously to Lemma 4.2 in [3]. To do so, we need to prove that any determinant of the vectors v1,v2,...,vnof Fnis a multiple of 2. Indeed, given any vector v= (x1, x2,...,xn)∈Fn,x1=Pn i=2 xi+ 2afor some integer a. Then v= 2a, x2− n X i=2 xi, x3− n X i=2 xi,...,xn− n X i=2 xi!. It follows that both |det (v1,v2,...,vn)|and that |det (v1,v2,...,w,...,vn)|, where w∈Fn, are divisible by 2. The following remark is used to find the wedges used to define the weighted ns-distance for Fn. Remark 9 The systems of equations                  1 1 1 ···1 1 1 1 0 0 ···0 0 0 0 1 0 ···0 0 0 . . .. . .. . ..... . .. . . 0 0 0 ···1 0 0 0 0 0 ···0 1 −1                                   a1 a2 a3 . . . an−1 an                  =                  x1 x2 x3 . . . xn−1 xn                  and                  1 1 1 ···112 1 0 0 ···000 0 1 0 ···000 . . .. . .. . ..... . .. . . 0 0 0 ···100 0 0 0 ···010                                   b1 b2 b3 . . . bn−1 bn                  =                  x1 x2 x3 . . . xn−1 xn                  . have solutions a1=x2 a2=x3 . . . an−2=xn−1 an−1=x1+xn−(x2+...+xn−1) 2 an=x1−(x2+x3+...+xn) 2and 7 b1=x2 b2=x3 . . . bn−1=xn bn=x1−(x2+x3+...+xn) 2 which are all non-negative when x1≥x2≥...≥xnand x1≥x2+x3+...+xn. The following lemma says that to find a shortest path between 0and any point p= (x1, x2,...,xn)∈Fnsuch that x1≥x2≥...≥xn≥0 and x1≤Pn i=2 xi, it is enough to use only 1-steps. Lemma 10 For any point p= (x1, x2,...,xn)∈Fnsuch that x1≥x2≥ ...≥xn≥0and x1≤Pn i=2 xi, the following algorithm terminates in x1+x2+...+xn 2 steps. Initially, let j= 1 and qj=p. ⋆Decrease the two largest coordinate values in qjby 1, increase jby 1and let the result be qj. Repeat ⋆until qj=0. PROOF. Since the sum of coordinates is even by definition, x1+x2+...+xn 2is an integer. It follows from x1≤Pn i=2 xithat, if qi6=0, there will always be at least two coordinates with positive values: Assume that this is not the case, then at some step qi= (b, 0,0,...,0), where b > 0. Since the coordinate with the largest value is decreased in each step, x1=b+Pn i=2 xi. But this contradicts that x1≤Pn i=2 xi.2 Now we give a formula that gives the ns-distance in the n-dimensional facecentered cubic grid. Theorem 11 (ns-distance in Fn)Let Fnbe wedge-2-generated by N1and N2and let the neighborhood sequence Band the point p= (x1, x2,...,xn) such that x1≥x2≥. . . ≥xn≥0be given. Then d(0,p;B) = min ll≥max x1+x2+...+xn 2, x1−2l B. PROOF. First the case x1≥x2+x3+...+xnis considered. With the neighborhoods N1and N1,2, we use 8 F1=                            (1,1,0,···,0,0,0) (1,0,1,···,0,0,0) . . . (1,0,0,···,0,0,1) (1,0,0,···,0,0,−1)                            and F2=                            (1,1,0,···,0,0,0) (1,0,1,···,0,0,0) . . . (1,0,0,···,0,0,1) (2,0,0,···,0,0,0)                            . By Lemma 8, the sets F1and F2are bases of Fnand by Remark 9, any point psuch that x1≥x2≥... ≥xnand x1≥x2+x3+...+xncan be written as a linear combination of vectors from F1and F2with positive coefficients. Therefore, F1and F2define the 1-wedge and 2-wedge for any point psuch that x1≥x2≥...≥xnand x1≥x2+x3+...+xn. Remark 9 gives the number of local steps needed to reach the point p, i.e., dC1(0,p;B) = Pai=x1and dC2(0,p;B) = Pbi=x1+x2+...+xn 2. Using Theorem 5, we get the formula in Theorem 11. For the case x1≤x2+x3+...+xn, we have not found the wedges in the general n-dimensional case. It is, however, clear that the ns-distance is x1+x2+...+xn 2 independent of the neighborhood sequence B(using only local steps from N1) as Lemma 10 shows. Since x1≤x2+x3+...+xn, the path hqj,qj−1,...,q1iobtained from the algorithm in Lemma 10 is a path of length x1+x2+...+xn 2using only local steps from N1. Also, x1+x2+...+xn 2≥x1≥x1−2k Bfor any Band k, so the formula in Theorem 11 is valid. 2 As one can see there are two cases. In the first case a shortest path is obtained by only 1-steps; while in the second case (x1> x2+...+xn) 2-steps should be considered to find the shortest path. Now we give the cost of a minimal cost path when the weights αand βare used. Theorem 12 (weighted ns-distance in Fn)Let Fnbe wedge-2-generated by N1and N2and let the ns B, the weights α,βs.t. 0< α ≤β≤2α, 9 r 2−γ γα +β−βγ ,γ γα +β−βγ ,0!and r1 α,1 α,0for dfcc and r 2−γ γα +β−βγ ,γ γα +β−βγ ,γ γα +β−βγ !and r1 α,1 α,1 αfor dbcc. The shape of the polyhedra obtained for some values of α, β, γ are shown in Figure 2 and 3 for the fcc and bcc grids, respectively. In approximations the ratio of αand βmatters. Let APbe the surface area and VPthe volume of the (region enclosed by the) polyhedron P. The values of APand VPare determined by the vertices of the polyhedra. Let Brbe a Euclidean ball of radius r. The following error functions are considered Fig. 3. Shapes of balls for dbcc α,β(·,·;γ) for a fixed radius r,α= 1, and (left to right) γ= 0,0.25,0.5,0.75,1 and (top to bottom) β= 1,1.25,1.5,1.75,2. 16 E1= max p,q∈∂P |p| |q|!−1 (relative error) (7) E2= A3 P V2 P 36π−1 (compactness ratio) (8) E3= min r:Br⊂P(VP/VBr)−1 (maximal inscribed ball) (9) E4= min r:P⊂Br (VBr/VP)−1 (minimal covering ball) (10) These error functions attain their minimum value 0 when Ais the surface area and Vis the volume of a Euclidean ball. The values of α,β, and γthat minimize the error functions are computed numerically. The polyhedra are given by their vertices, given above. All error functions attain a minimum value within the domain 0 < α ≤β≤2α, 0 ≤γ≤1, so the computation is straight-forward (when an analytic solution could not be found, the Nelder- Mead simplex method was used). The error function E1gets optimal value not only in a point when weights are used on the fcc grid. In these cases the parameters C1, C2and C3are used in Table 1. C1can be any value such that √2≤C1≤5/3.(11) Moreover, C3can be any value in the range 0 ≤C3≤2(√2−1) and C2any value satisfying the following inequalities (see also Figure 7): qC2 3+ 2 −2C3−C3 1−C3≤C2≤min   √3−C31 2√3 + 1 1−C3 ,5 3 .(12) For the relative error on the fcc grid, the optimum is obtained on a region as shown in Figure 7. The optimal values are found in Table 1 and visualized by the shape of the corresponding polyhedra in Figure 6. In Figure 4 and 5, the asymptotic behavior is shown by letting α= 1 and βbe constant and for each k, 1 ≤k≤1000 using a ns Bof length kthat approximates the optimal fraction γ. The values of the error functions and k are plotted in the figures. The plots in Figure 4 and 5 show how the error functions perform for ns of finite lengths (periodic ns). Neighborhood sequences obtained by the following recursive formula are used b(k+ 1) =      1 if 1k B< γk, 2 otherwise. The value of γis shown in Table 1. When γis not uniquely defined, we use constant values within the allowed interval. The same thing applies to β. 17 Table 1 Performance of wns-, weighted- (w), and ns-distances using the error functions E1− E4defined in the text. The optima of the error functions are attained whenever tis a strictly positive real number. The values shown in bold are fixed in the optimization. The parameters C1,C2, and C3are related as is shown in inequalities (11) and (12). Relative error, E1 fcc bcc Name α β γ E1α β γ E1 wt C1t00.2247 t1.1547t00.2393 ns 1 1 0.8453 0.2393 1 1 [1/3,2−√2] 0.2247 wns t C2t C30.2247 t t [1/3,2−√2] 0.2247 Compactness ratio, E2 fcc bcc Name α β γ E2α β γ E2 wt1.5302t00.1367 t1.2808t00.1815 ns 1 1 0.8453 0.2794 1 1 2−√2 0.2147 wns t1.4862t0.4868 0.1267 t1.2199t0.4525 0.1578 Maximal inscribed ball, E3 fcc bcc Name α β γ E3α β γ E3 wt(5/3)t00.1578 t1.2808t00.1815 ns 1 1 0.8453 0.2794 1 1 2−√2 0.2147 wns t(5/3)t0.3280 0.1563 t1.2199t0.4525 0.1578 Minimal covering ball, E4 fcc bcc Name α β γ E4α β γ E4 wt√2t00.4234 t1.1547t00.5708 ns 1 1 0.7408 0.4448 1 1 1/3 0.3860 wns t1.2179t0.5425 0.3272 t t 1/3 0.3860 18 E1 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 β= 1,γ= 0.8453 β= 1.5, γ= 0 E2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 β= 1,γ= 0.8453 β= 1.4862,γ= 0.4868 E3 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 β= 1,γ= 0.8453 β= 5/3,γ= 0.3280 E4 01.1 1.2 1.3 1.4 1.51.6 1.7 1.8 1.9 3 0 0.5 1 1.5 2 2.5 3 1 1.5 2 2.5 3 3.5 4 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 β= 1,γ= 0.7408 β= 1.2179,γ= 0.5425 Fig. 4. Optimal values of E1–E4(vertical axis) on the fcc grid for neighborhood sequences of length k(0 < k ≤1000, horizontal axis showing log10 k) with α= 1. See Table 1 for asymptotic optima. 19 E1 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 β= 1,γ= 0.5β= 1,γ= 0.5 E2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 β= 1,γ= 2 −√2β= 1.2199,γ= 0.4525 E3 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 01.1 1.2 1.3 1.4 0.51.6 1.7 1.8 1.9 1 0 0.5 1 1.5 2 2.5 3 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 β= 1,γ= 2 −√2β= 1.2199,γ= 0.4525 E4 01.1 1.2 1.3 1.4 11.6 1.7 1.8 1.9 2 0 0.5 1 1.5 2 2.5 3 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3 01.1 1.2 1.3 1.4 11.6 1.7 1.8 1.9 2 0 0.5 1 1.5 2 2.5 3 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3 β= 1,γ= 1/3β= 1,γ= 1/3 Fig. 5. Optimal values of E1–E4(vertical axis) on the bcc grid for neighborhood sequences of length k(0 < k ≤1000, horizontal axis showing log10 k) with α= 1. See Table 1 for asymptotic optima. 20 fcc bcc E1 β= 1.414 β= 1 β= 1.5β= 1.154 β= 1 β= 1 γ= 0 γ= 0.845 γ= 0.3γ= 0 γ= 0.586 γ= 0.586 E2 β= 1.530 β= 1 β= 1.486 β= 1.281 β= 1 β= 1.220 γ= 0 γ= 0.845 γ= 0.487 γ= 0 γ= 0.586 γ= 0.453 E3 β= 1.667 β= 1 β= 1.667 β= 1.281 β= 1 β= 1.220 γ= 0 γ= 0.845 γ= 0.328 γ= 0 γ= 0.586 γ= 0.453 E4 β= 1.414 β= 1 β= 1.218 β= 1.155 β= 1 β= 1 γ= 0 γ= 0.741 γ= 0.543 γ= 0 γ= 0.333 γ= 0.333 Fig. 6. Shapes of balls using α= 1 and values of βand γthat minimize E1–E4, see Table 1. 21 1 1.25 1.5 1.75 2 0 0.25 0.5 0.75 1 C2 C3 Fig. 7. The domain for C2and C3in Table 1 4 Conclusions We have given generalizations of the fcc and bcc grids to any dimension. For these grids, formulas for the ns-distance and weighted ns-distance were presented. We note that the weighted ns-distance in Bnbetween 0and a point ponly depends on the two coordinates of pwith highest absolute value. For Fn, all coordinates are needed to calculate the distance values. In 4D bcc the Euclidean distance of the 1-neighbors are the same as the 2- neighbors. In higher dimensions the 2-neighbors have less Euclidean distance, therefore it seems to be fruitful to consider weights β < α for future research. By introducing a number of error functions that all favor “round” balls (in the Euclidean sense), the weighted ns-distance is analyzed for the fcc and bcc grids. It turns out that the optimal parameters for the special cases of weighted distances (γ= 0 or B= (2)) and ns-distances (α=β= 1) are also found from this procedure by keeping one of the parameters fixed in the optimization. The same weights and neighborhood sequences as were derived for weighted distances [2,3] and ns-distances [4] are found in this paper. Figure 2 and 3 gives an overview of this fact – weighted distances are shown in the left columns (γ= 0) and ns-distances are shown in the top rows (β= 1). We also note that, as expected, the value of the error functions for the wns distance function are lower than (or, in some cases, equal to) the weighted distance and ns-distance. We use the coordinates of the vertices of polyhedra corresponding to the asymptotic shape of the balls in the fcc and bcc grids. Note that the ver- 22 tices can be found also for higher-dimensional generalizations of the fcc and bcc grids. Since the optimization methods use geometric features, such as area and volume, their extensions to higher dimension should be used. The parameter optimization in higher dimensions is left for future research. In the optimization, we let γrepresent the fraction of 1:s in the ns. We note that when γis fixed to 0 (for weighted distances), this corresponds to a ns with only 2:s. This can be attained for a neighborhood sequence of any length. Therefore, in this case the optimum is not asymptotic and thus, the error is valid also for short distances (between e.g. neighboring grid points). When γ is also subject to optimization (i.e. when the neighborhood sequence is used to define the distance function), the error functions have an asymptotic behavior. However, some of the optima for the relative error (E1) are located on regions where E1is constant. For example, E1for the weighted ns is optimal when γ= 0, i.e. for the weighted distance, and therefore the optimum is attained for any neighborhood sequence consisting of only 2:s. See Figure 4 and 5 and Figure 7. This indicates that this error function, which has been widely used in the literature, is not well-suited for finding the optimal weights and ns here. The reason that E1is minimal on a region (and not a point) is that there are two vertices and two surfaces that have points that can be at minimal distance (up to symmetry). Thus, there are more degrees of freedom than the restrictions in the optimization process. For the other error functions (E2–E4), differentiable functions are defined and they have all a single minimum, see Table 1. We note that the error functions E2(compactness ratio) and E3(maximal inscribed ball) give the same asymptotic optimal result for the bcc grid and the same for ns-distances on the fcc grid, see Table 1. However, as is seen in Figure 4 and 5, the error functions perform differently for finite, i.e., periodic, neighborhood sequences. This illustrates that the different error functions are different, even though they all are used to approximate the Euclidean distance. Different applications require different aspects of the “roundness” of the balls and different types of rotational (in)dependency. Analyzing the plots in Table 1, we see that the error converges quite fast and that a ns of length (period) 10 is sufficient in general. The application in which the distance function will be applied should be used to select which error function that should be considered. Also, by using Theorem 17, it is easy to find neighborhood sequences such that the resulting distance function is a metric, which is preferable in many applications. Intuitively, the polyhedra that best approximate the Euclidean ball are given by a distance function where both γand βare non-trivial, see Figure 2 and 3. From the “optimal shapes” in Figure 6, we see that this is what, e.g., the compactness ratio E2favors. Thus, without any specific application in mind, we suggest 23 the parameters B= (1,2), β= 1.4862αfor the fcc grid and β= 1.2199αfor the bcc grid. This gives E2= 0.1276 for the fcc grid (the optimum is 0.12757 and the approximated value is 0.12760) and E2= 0.1591 (the optimum is 0.1578) for the bcc grid. We conclude that we get a good approximation of the optimal values also with a short neighborhood sequence. Acknowledgements A preliminary version of the paper was presented at the 12th International Workshop on Combinatorial Image Analysis, Buffalo, NY, USA, April 2008 [28]. The authors thanks the audience of IWCIA 2008 for their useful comments and questions. The research is supported by Digital geometry with applications in image processing in three dimensions (DIGAVIP) at Center for Image Analysis, Uppsala University. References [1] S. Matej, R. M. Lewitt, Efficient 3D grids for image reconstruction using spherically-symmetric volume elements, IEEE Transactions on Nuclear Science 42 (4) (1995) 1361–1370. [2] R. Strand, G. Borgefors, Distance transforms for three-dimensional grids with non-cubic voxels, Computer Vision and Image Understanding 100 (3) (2005) 294–311. [3] C. Fouard, R. Strand, G. Borgefors, Weighted distance transforms generalized to modules and their computation on point lattices, Pattern Recognition 40 (9) (2007) 2453–2474. [4] R. Strand, B. Nagy, Distances based on neighbourhood sequences in nonstandard three-dimensional grids, Discrete Applied Mathematics 155 (4) (2007) 548–557. [5] H. Carr, T. Theussl, T. M¨oller, Isosurfaces on optimal regular samples, in: C. D. H. G.-P. Bonneau, S. Hahmann (Ed.), Proceedings of the symposium on Data visualisation 2003, Eurographics Association, 2003, pp. 39–48. [6] R. Strand, P. Stelldinger, Topology preserving marching cubes-like algorithms on the face-centered cubic grid, in: Proceedings of 14th International Conference on Image Analysis and Processing (ICIAP 2007), Modena, Italy, 2007, pp. 781– 788. [7] C. Hamitouche, L. Ibanez, C. Roux, Discrete topology of A∗ noptimal sampling grids. interest in image processing and visualization, Journal of Mathematical Imaging and Vision 23 (3) (2005) 401–417. 24 [8] J. H. Conway, N. J. A. Sloane, Sphere Packings, Lattices and Groups, Grundlehren der Mathematischen Wissenschaften 290, Springer-Verlag, New York, 1988. [9] R. Klette, A. Rosenfeld, Digital Geometry: Geometric Methods for Digital Image Analysis (The Morgan Kaufmann Series in Computer Graphics), Morgan Kaufmann, 2004. [10] D. Coeurjolly, S. Miguet, L. Tougne, 2D and 3D visibility in discrete geometry: an application to discrete geodesic paths, Pattern Recognition Letters 25 (5) (2004) 561–570. [11] B. J. H. Verwer, P. W. Verbeek, S. T. Dekker, An efficient uniform cost algorithm applied to distance transforms, IEEE Transactions on Pattern Analysis and Machine Intelligence 11 (4) (1989) 425–429. [12] R. Strand, F. Malmberg, S. Svensson, Minimal cost-path for path-based distances, in: Proceedings of 5th International Symposium on Image and Signal Processing and Analysis (ISPA 2007), Istanbul, Turkey, 2007, pp. 379–384. [13] G. Borgefors, Distance transformations in digital images, Computer Vision, Graphics, and Image Processing 34 (1986) 344–371. [14] A. Rosenfeld, J. L. Pfaltz, Distance functions on digital pictures, Pattern Recognition 1 (1968) 33–61. [15] A. Rosenfeld, J. L. Pfaltz, Sequential operations in digital picture processing, Journal of the ACM 13 (4) (1966) 471–494. [16] M. Yamashita, T. Ibaraki, Distances defined by neighborhood sequences, Pattern Recognition 19 (3) (1986) 237–246. [17] P. P. Das, Best simple octagonal distances in digital geometry, Journal of Approximation Theory 68 (1992) 155–174. [18] P. P. Das, B. N. Chatterji, Octagonal distances for digital pictures, Information Sciences 50 (1990) 123–150. [19] J. Farkas, S. Baj´ak, B. Nagy, Notes on approximating the Euclidean circle in square grids, Pure Mathematics and Applications 17 (2006) 309–322. [20] B. J. H. Verwer, Local distances for distance transformations in two and three dimensions, Pattern Recognition Letters 12 (11) (1991) 671–682. [21] A. Hajdu, B. Nagy, Approximating the Euclidean circle using neighbourhood sequences, in: Proceedings of 3rd Hungarian Conference on Image Processing, Domasz´ek, 2002, pp. 260–271. [22] A. Hajdu, L. Hajdu, Approximating the Euclidean distance using non-periodic neighbourhood sequences, Discrete Mathematics 283 (2004) 101–111. 25