Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

>f 532 IEEE TRANSACTIONS ON COMPUTERS, MAY 1976

[9] P. S. Poretski, ."La loi des racines en logique," Rev. de Math., vol. [17] A. Thayse, "On some iteration properties of Boolean functions,"
6, pp. 5-8, 1896. Philips. Res. Rep., vol. 28, pp. 107-119, 1973.
[10] C. Reischer and D. A. Simovici, "Associative algebraic structures
in the set of Boolean functions and some applications in automa-
ta theory," IEEE Trans. Computers, vol. C-20, pp. 298-303, .- Sergiu Rudeanu was born on February 9,
1971. 1935 in Iasi, Romania. He graduated and re-
[11] S. Rudeanu, "Solutions non redondantes des equations Boo- ceived the Ph.D. degree in mathematics from
leennes," Bull. Math. Soc. Sci. Math. Phys. R. P. Roumaine, vol. the University of Bucharest, Bucharest, Ro-
7, pp. 45-49, 1963.
[12] -, "Remarks on Motinori Goth's papers on Boolean equa- nmania, in 1957 and 1964, respectively.
tions," Rev. Roumaine Math. Pures AppI., vol. 10, pp. 311-317, From 1958 to 1968 he was a Research Scien-
1965. tist at the Institute of Mathematics of the Ro-
[131 "Irredundant solutions of Boolean and pseudo-Boolean manian Academy, Bucharest. Since 1968 he
equations," Rev. Roumaine Math. Pures Appl., vol. 11, pp. 183- f[ _l has been an Associate Professor with the Fac-
188, 1966 ulty of Mathematics at the University of Bu-
[14] -, Boolean Functions and Equations. Amsterdam/London: A _ charest. During the period 1974-1976 he was
North-Holland Publ. Co., 1974. with the Institute of Mathematics at the University of Oran, Es-Senia,
[151 --, "An algebraic approach to Boolean equations," IEEE Algeria. His fields of interest are lattice theory and Boolean algebra
Trans. Computers, vol. C-23, 1974.
[16] E. Schroder, Vorlesungen uber die Algebra der Logik. Leipzig, with applications to switching theory, integer , programming, and
vol. 1, 1890; vol. 2, 1891, 1905; vol. 3, 1895. Reprint, Bronx, NY; graph theory. He has published about 50 research papers and 3 books
Chelsea, 1966. in these areas.

<: Correspondence.
Distance on a Hexagonal Grid d4(i,j), (h,k)) -Ili - hl + Ij - kl.
ED LUCZAK AND AZRIEL ROSENFELD We can define an 8-path from (i,j) to (h,k) analogously, ex-
cept that we allow diagonal, as well as horizontal and vertical,
Abstract-A simple formula is derived for the distance be- neighbors. The chessboard distance between (i,j) and (h,k) is
tween two points on a hexagonal grid, in terms of coordinates defined as the length of the shortest such 8-path, and it can be
F with respect to a pair of oblique axes. shown that this is given by

Index Terms-Distance, hexagonal grid, pattern recognition, d8((i,j), (h,k)) = max (Ii - hl, i - kl).
picture processing. It can be verified that both d4 and d8 are metrics, which
means that for all points (i,j), (h,k), and (u,v) we have
Distance functions, or metrics, on digital pictures have been
used in a number of picture processing applications [1, section d((i,j), (h,k)) = 0 if and only if
8.3]. Such functions are usually defined on the conventional (i,j) = (h,k) (positive definiteness)
Cartesian grid. It is well known that there are certain advan-
tages in using a hexagonal rather than a Cartesian grid to rep- d((i,j), (h,k)) = d((h,k), (i,j)) (symmetry)
resent a digital picture, and picture operations based on such
grids have been studied by various authors (e.g., [2]-[5]). The d((i,j), (h,k)) < d((i,j), (u,v))
purpose of this note is to develop a simple formula for dis- + d((u,v), (h,k)) (the triangle inequality)
tance on a hexagonal grid.
We first briefly review some basic results for the Cartesian for both d = d4 and d = d8.
case. Let (i,j) and (h,k) be two grid points, and define a 4- Suppose now that we are given a hexagonal grid such as that
path from (i,j) to (h,k) as a sequence of points shown (partially and approximately) in Fig. 1. We can intro-
**X(i,) = (io,jo), (il,jl), - --, (inj,j) = (h,k) duce a coordinate system on such a grid by using any two of
the three axes shown in the figure, say x and y. Given any
in which (ir,jr) is a horizontal or vertical neighbor of point P on the grid, we can reach P from the origin by making
(ir-,Jr-i) 1 S< r S n. The city block distance between (i,j) an integer number r of moves (positive, negative, or zero) in
and (h,k) is defined as the length of the shortest such 4-path the +x direction, and then an integer number s of moves in
(i.e., the one having smallest n). It is not hard to see that this the +y direction; then (r,s) are the coordinates of P. In the re-
distanceis given by mainder of the discussion, the oblique coordinates of a point
will always be given with respect to the x and y axes of Fig. 1.
The x, y, and z axes divide the plane into six sextants,
Manuscript received May 19, 1975; revised October 21, 1975. This which we shall number counterclockwise beginning at the +x
workwas supported by the Division of Computing Research, National axis, as shown in Fig. 1. It is easily verified that coordinates of
Science Foundation under Grant GJ-32258X.
The authors are with the Computer Science Center, University of points lying in these sextants can be characterized as follows.
Maryland, College Park, MD 20742. Note that the z-axis is the locus of points such that r + s = 0.
CORRESPONDENCE 533

II
Sextant r s r+s z y

1 >0 >0 >0 III . . .


II <0 >0 >0
IlI <0 >0 <0
IV <0 s0 <0
V >0 <0 .0
VT >0 .0 >0
N
IV
Let us now define a 6-path from (i,j) to (h,k), on the hexag-
onal grid, just as above, where successive points on the path
are neighbors in the grid; note that a point has six such neigh-
bors. The hexagonal distance between (i,j) and (h,k) is de- .v VI
fined as the length of the shortest such path. The main result Fig. 1. Hexagonal grid.
of this note can now be stated.
Proposition: The hexagonal distance between (i,j) and (h,k)
is given by 1), and (i +- 1j + 1), while a point on an even-numbered row
has the six neighbors (i i 1,j), (i,j ± 1), and (i - ii I 1).
d6((i,j), (h,k)) Ii-i-hi + I] - ki, With respect to the Cartesian coordinate system on the un-
if (i - h) and (j -k) have the same sign shifted grid, it was shown in [61 that the distance between (i4)
max (Ii - hl, Ij - kl), if they have opposite signs. and (hk), as defined by the length of shortest path using the
above definitions of neighbors, is given by
Proof: Neither the distance nor the coordinate differences
change when the origin of the coordinate system is translated; maxrji-kt,4(ti-kl +j-k)
hence we can choose it to be at (h,k). Thus, it suffices to prove
that
1 [2 ] +11
[2] rk_± +1
d6((i,j), (0,0)) = n if and only if
k

il + ij = n, if i and j have the same sign 2 (i - kl-j + k) - 2 ] 2 h+


lmax(j il, lIj) = n, if they have opposite signs.
Now our hexagonal coordinates (r,s) are related to these Car-
Note that i and j have the same sign for (i,j) in sextants I or tesian coordinates (i,j) by
IV, and opposite signs otherwise. Moreover, in sextants II and
Vwehave Iil < ljl (e.g., in Ilwe havei < 0,j > 0,buti +ji 0,
so that Itj is bigger than lit ), which implies that max (Iil, Itjl)
ljl; and similarly, in sextants III and VI we have 1il 2 lijt so
r rj
S=j-[
that max(l it Ili) = i.
The proof proceeds by induction on n. If n = 0, (i,j) is (0,0), for j even, and by
so that its distance from (0,0) is 0, and we also have lil + lIj =
0. Suppose the assertion is true for integers less than n. We
consider first the case where (i,j) is interior to (say) sextant I,
so that its six neighbors also all lie in sextant I. s=i
Let d6((ij), (0,0)) = n; then Iil + ljl > n, since if it were <n, for odd. It can be verified, by enumeration of cases, that the
we would have d6((i,j), (0,0)) < n by induction hypothesis. distance j
Now a shortest path from (0,0) to (i,j) must pass through one formula; formula in our proposition is equivalent to the above
of the neighbors, so that there is a neighbor (h,k) at distance n the details will not be given here. Since our formula
- 1 from (0,0). By induction hypothesis, Ihl + Ikj = n - 1. But is much simpler, both conceptually and computationally, it
readily, the neighbors of any point (h,k) have coordinates would seem advantageous to use the oblique coordinate sys-
tem introduced here, when working with a pseudohexagonal
(h,k-1), (h,k + 1), (h-1,k), grid, rather than using Cartesian coordinates. This would
(h + 1,k), (h - 1,k + 1), and (h + 1,k - 1). greatly simplify computations involving distances, while per-
mitting the use of the d6 metric, which is a better approxima-
Since h and k have the same sign, for each of these points tion to Euclidean distance than either d4 or d8.
(u,v) we have Iul + Ivl < n. Thus, in particular, Iil + ljl < n,
which proves il + I jt = n. ACKNOWLEDGMENT
Conversely, let lil + Iji = n; then d6((i,j), (0,0)) < n, since if The authors wish to -thank S. Rowe for her help in preparing
it were <n we would have lil + lil < n by induction hypothe- the manuscript and the referees for their useful suggestions.
sis. Now (i,j) has neighbors (u,v), namely (i - 1,j) and (i,J -
1), for which tul + Ivt = n - 1, so that d6((U,V), (0,0)) = n - 1; REFERENCES
hence d6((i,j), (0,0)) < n, and so = n. [1] A. Rosenfeld, Picture Processing by Computer. New York: Aca-
The proofs for (ij) interior to other sextants, or on sextant demic, 1969.
boundaries (i.e., on the x, y or z axis), are similar, and the de- [2] M. J. E. Golay, "Hexagonal parallel patternAug. transformations,"'
tails will not be given here. o IEEE Trans. Comput., vol.- C-18, pp. 733-740, 1969.
One way of creating a "pseudohexagonal"' gridl is to regard [31 S. B. Gray, "Local properties of binary images in two dimensions,"
IEEE Trans. Comput., vol. C-20, pp. 551-561, May 1971.
the odd-numbered rows of a Cartesian grid as shifted i unit [41 E. S. Deutsch, "Thinning algorithms on rectAngular, hexagonal,
to the right (say); see Fig. 1. This is equivalent to working with and triangular arrays," Commun. Ass. Comput. Mach. vol. 15, pp.
an unshifted Cartesian grid, but treating a point (i,j) on an [5] 827-837, 1972.
C. T. Zahn, "Region boundaries on a triangular grid," in Proc. 2nd
odd-numbered row as having the six neighbors (i I 1j), (i,j Int. Joint Conf. Pattern Recognition, Aug. 1974, pp. 136-140.
16] A. Rosenfeld and J. L. Pfaltz, "Distance functions on digital pic-
I With axes close to the 60° directions, e.g., tan-12 = 63.40. tures," Pattern Recognition, vol. 1, pp. 33-62, 1968.

You might also like