+ All Categories
Home > Documents > Chain Coding with a Hexagonal Lattice

Chain Coding with a Hexagonal Lattice

Date post: 07-Nov-2016
Category:
Upload: stephen-g
View: 213 times
Download: 1 times
Share this document with a friend
8
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983 Fig. 15. 3-D seed construction. Fig. 16. Eight 3-D seeds. The net effect of traversing the whole distance of a seed curve of dimension n is a unit step in dimension n. A simple example of this is the generation of a three-dimen- sional seed curve 53 from the two-dimensional seed curve S2. Fig. 10 shows S2, and by tracing S2, a single step into the third dimension (0, 0, 1) followed by the inverse of S2, the curve 53 is obtained (Fig. 15). The whole curve consists of S2 (0, 0, 1) - S2 i.e., (1) with n = 2. The three-dimensional Peano curve is constructed by replac- ing the seed curve with eight similar seed curves (Fig. 16). The technique can be continued to arbitrary quantization or dimen- sion to produce the required curve, which may contain ele- ments of mixed dimension or resolution. The algorithm en- ables simple programs or hardware to generate the curves. For the computer program, there is a table of the eight possible ways of drawing the curve in two dimensions. Each of these seed curves can be described in terms of the four curves from the table that replace it when a greater quantization is required. For three dimensions, a table of 24 curves is required. REFERENCES [1] G. Peano, Selected Works of Guiseppe Peano, H. C. Kennedy, Trans. and Ed., Allen and Unwin, ISBN-0-04-164002-0. [2] J. C. Simon and J. Quinqueton, C. R. Acad. Sci. Paris, vol. 286, Apr. 10, 1978. [3] B. Mandelbrot, Fractals-Form, Chance and Dimension. W. H. Freeman, ISBN 0-7167-0473-0. [41 E. A. Patrick, D. R. Anderson, and F. K. Bechtel, "Mapping multi- dimensional space to one dimension for computer output display," IEEE Trans. Comput., pp. 949-953, Oct. 1968. [5] A. R. Butz, "Alternative algorithm for Hilbert's space-filling curve," IEEE Trans. Comput., vol. C-20, pp. 424-426, Apr. 1971. Chain Coding with a Hexagonal Lattice DANIEL K. SCHOLTEN AND STEPHEN G. WILSON Abstract-This paper investigates the performance of chain code quantization of general curves using a hexagonal lattice structure, as a means of improving efficiency over the standard square lattice. Performance is first computed theoretically, assuming a generalization of grid-intersect quantization, and the curve to be quantized is assumed to be a straight line. An algorithm is then developed to perform chain coding using the hex lattice. Computer simulations were performed to evaluate hexagonal chain coding for a variety of curves, including circles of various curva- ture, straight lines, and a stochastic curve model. We fmd that the straight-line theory is substantiated for curves whose radius of curvature is roughly twice the lattice constant. For a given peak error in quanti- zation, hexagonal coding reduces the bit rate about 15 percent relative to the square lattice codes, and exhibits qualitative improvements in fidelity as well. Index Terms-Chain codes, geometric probability, hexagonal lattice, infonnation theory, lattice quantization region, line quantization, rate- distortion theory. I. INTRODUCTION Quantization of line drawings must be performed whenever such images are to be stored or transmitted digitally. Efficient quantization minimizes the number of bits of information that is handled. When storing data, this minimizes the space re- quired; when transmitting data, transmission time is minimized. Chain codes are one simple way of encoding the information in a quantized curve, by recording only transitions between successive points in a lattice, not absolute coordinates. Free- man [ 1], [ 2 ] provides a summary of such methods. Any regular lattice can provide chkain points, but those formed by vertices of regular polygons are the simplest and most natural. While triangular and hexagonal lattices have been mentioned, only the square lattice has apparently received much attention. Freeman [2] has studied the performance of chain codes using the standard square lattice in detail. He has analyzed three different quantization sch-emes for the square lattice, referred to as square quantization, circular quantization, and grid-intersect quantization. If the actual curve intersects a lattice point's quantization region, that point is added to the chain code (the transition to that point is added to the list of transitions). Koplowitz [3] invoked results of geometric probability the- ory to establish a rate-distortion equation for encoding of straight lines randomly cast on the plane. Presumably, the modeling applies as well in practical cases where line drawings with small curvature are to be chain-coded. Letting e denote the maximum encoding error between the actual curve and the quantized curve, Koplowitz [3] estab- lished that for grid-intersect quantization be= 1.35 (1) where b is the bit requirement in bits per unit curve length. As Manuscript received December 16, 1981; revised May 10, 1982. D. K. Scholten was with the Department of Electrical Engineering, University of Virginia, Charlottesville, VA 22901. He is now with The Analytic Sciences Corporation, Reading, MA 01867. S. G. Wilson is with the Department of Electrical Engineering, Uni- versity of Virginia, Charlottesville, VA 22901. 0162-8828/83/0900-0526$01.00 © 1983 IEEE 526
Transcript

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

Fig. 15. 3-D seed construction.

Fig. 16. Eight 3-D seeds.

The net effect of traversing the whole distance of a seedcurve of dimension n is a unit step in dimension n.A simple example of this is the generation of a three-dimen-

sional seed curve 53 from the two-dimensional seed curve S2.Fig. 10 shows S2, and by tracing S2, a single step into thethird dimension (0, 0, 1) followed by the inverse of S2, thecurve 53 is obtained (Fig. 15).The whole curve consists of

S2 (0, 0, 1) - S2

i.e., (1) with n = 2.The three-dimensional Peano curve is constructed by replac-

ing the seed curve with eight similar seed curves (Fig. 16). Thetechnique can be continued to arbitrary quantization or dimen-sion to produce the required curve, which may contain ele-ments of mixed dimension or resolution. The algorithm en-ables simple programs or hardware to generate the curves. Forthe computer program, there is a table of the eight possibleways of drawing the curve in two dimensions. Each of theseseed curves can be described in terms of the four curves fromthe table that replace it when a greater quantization is required.For three dimensions, a table of 24 curves is required.

REFERENCES

[1] G. Peano, Selected Works of Guiseppe Peano, H. C. Kennedy,Trans. and Ed., Allen and Unwin, ISBN-0-04-164002-0.

[2] J. C. Simon and J. Quinqueton, C. R. Acad. Sci. Paris, vol. 286,Apr. 10, 1978.

[3] B. Mandelbrot, Fractals-Form, Chance and Dimension. W. H.Freeman, ISBN 0-7167-0473-0.

[41 E. A. Patrick, D. R. Anderson, and F. K. Bechtel, "Mapping multi-dimensional space to one dimension for computer output display,"IEEE Trans. Comput., pp. 949-953, Oct. 1968.

[5] A. R. Butz, "Alternative algorithm for Hilbert's space-filling curve,"IEEE Trans. Comput., vol. C-20, pp. 424-426, Apr. 1971.

Chain Coding with a Hexagonal Lattice

DANIEL K. SCHOLTEN AND STEPHEN G. WILSON

Abstract-This paper investigates the performance of chain codequantization of general curves using a hexagonal lattice structure, as ameans of improving efficiency over the standard square lattice.Performance is first computed theoretically, assuming a generalization

of grid-intersect quantization, and the curve to be quantized is assumedto be a straight line.An algorithm is then developed to perform chain coding using the hex

lattice. Computer simulations were performed to evaluate hexagonalchain coding for a variety of curves, including circles of various curva-ture, straight lines, and a stochastic curve model. We fmd that thestraight-line theory is substantiated for curves whose radius of curvatureis roughly twice the lattice constant. For a given peak error in quanti-zation, hexagonal coding reduces the bit rate about 15 percent relativeto the square lattice codes, and exhibits qualitative improvements infidelity as well.

Index Terms-Chain codes, geometric probability, hexagonal lattice,infonnation theory, lattice quantization region, line quantization, rate-distortion theory.

I. INTRODUCTIONQuantization of line drawings must be performed whenever

such images are to be stored or transmitted digitally. Efficientquantization minimizes the number of bits of information thatis handled. When storing data, this minimizes the space re-quired; when transmitting data, transmission time is minimized.Chain codes are one simple way of encoding the information

in a quantized curve, by recording only transitions betweensuccessive points in a lattice, not absolute coordinates. Free-man [ 1], [ 2 ] provides a summary of such methods.Any regular lattice can provide chkain points, but those formed

by vertices of regular polygons are the simplest and mostnatural. While triangular and hexagonal lattices have beenmentioned, only the square lattice has apparently receivedmuch attention.Freeman [2] has studied the performance of chain codes

using the standard square lattice in detail. He has analyzedthree different quantization sch-emes for the square lattice,referred to as square quantization, circular quantization, andgrid-intersect quantization. If the actual curve intersects alattice point's quantization region, that point is added to thechain code (the transition to that point is added to the list oftransitions).Koplowitz [3] invoked results of geometric probability the-

ory to establish a rate-distortion equation for encoding ofstraight lines randomly cast on the plane. Presumably, themodeling applies as well in practical cases where line drawingswith small curvature are to be chain-coded.Letting e denote the maximum encoding error between the

actual curve and the quantized curve, Koplowitz [3] estab-lished that for grid-intersect quantization

be= 1.35 (1)where b is the bit requirement in bits per unit curve length. As

Manuscript received December 16, 1981; revised May 10, 1982.D. K. Scholten was with the Department of Electrical Engineering,

University of Virginia, Charlottesville, VA 22901. He is now withThe Analytic Sciences Corporation, Reading, MA 01867.

S. G. Wilson is with the Department of Electrical Engineering, Uni-versity of Virginia, Charlottesville, VA 22901.

0162-8828/83/0900-0526$01.00 © 1983 IEEE

526

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

Randor

Line

(a) (b) (c)

Grid-Intersectquantization

Fig. 1. Hexagonal lattice, with possible quantization regions.

expected, (1) shows that if maximum error is to be reduced,the bit rate must be increased. In addition, the be productsfor square and circular quantization were found to be 1.50 and1.80, respectively, indicating poorer rate-distortion behaviorfor these methods.Other lattice structures are investigated in this paper. A gen-

eral grid-intersect quantization region is created by connectingmidpoints of adjacent lattice lines by a straight line. UsingKoplowitz' methodology, the triangular lattice, having latticepoints as vertices of packed equilateral triangles, was found tohave be = 1.41 for grid-intersect quantization. Since its per-formance was slightly worse than that of the square lattice, itwas not pursued. The hexagonal lattice (see Fig. 1), however,has be = 1.14 for grid-intersect quantization. This is a signifi-cant improvement over the standard square lattice, and war-ranted further study.

II. THEORY

The theory for computing be for the hexagonal lattice is sim-ilar to that done by Koplowitz [3] using a square lattice.

First, a triangular quantization region analogous to the dia-mond shaped grid-intersect region for the square lattice ischosen [see Fig. 1(b)]. As before, if the curve intersects aquantization region, the corresponding lattice point becomespart of the chain. Equivalently, whenever the curve intersectsa lattice line, the nearest node becomes a chain element, so wehave "grid-intersect" coding on a hexagonal lattice.The following quantities are defined for our development:

Region 2

(Overlayedtriangle)

Region 1

(Quantizationregion)

Fig. 2. Triangular region surrounding hexagonal lattice point.

Notice that a set of triangles can be constructed, one trianglecentered on each hexagonal lattice point, which completelytile the plane (without any gaps). We are essentially overlayinga triangular lattice on top of the hexagonal lattice. The grid-intersect quantization regions will be the smaller triangles,shown as dotted lines (see Fig. 2).To find Nc, two lemmas from geometric probability theory

[4] are used.Lemma 1: Consider a convex region H of perimeter h con-

tained in a region G of perimeter g. The probability of a ran-dom line intersecting H given that it intersects G is h/g.Lemma 2: Consider a convex region with perimeter P and

area A. The expected length of a chord formed by the inter-section of the region and a random line is Air/P.Consider a random line intersecting a large triangle (see Fig. 2).

Call the inner triangle (the lattice point's quantization region)region 1 and the outer triangle region 2. From Lemma 1, theprobability that the line intersects region 1 given that it inter-sects region 2 is the ratio of perimeters of the two regions:P1/P2. This is the probability of a new lattice point in thechain code, given that the actual curve intersects the outertriangle.By dividing this probability by the average length of the

curve inside the outer triangle, we get the average number ofnew lattice points per unit length of curve, E[NC] . If we nowassume the actual curve to be quantized is a straight line overone lattice region, i.e., the curvature is small in relation to thegrid size, the average length of the curve inside the outer tri-angle (region 2) will equal the average length of a random chordof the triangle. This chord length will equal A 2rr/P2, fromLemma 2. Then

E[] expected valueT lattice constant, the minimum distance between two

lattice pointsLC length of a chord of a random curve as it intersects the

hexagonal lattice regionLq length of the quantized curve, over the hexagonal regionLt length of a chain-code transitionSm LcIE[Lq ]. Ratio of curve length to expected quantized

curve lengthNC number of quantized curve points per unit length of

curvebe the product of the expected number of bits per unit

length of the encoded curve and the peak encodingerror.

E[N, ] = (PI/P2)/(A 2r/P2) = P/1 (A 2 * 7r). (2)

For the hexagonal lattice, using generalized grid-intersectquantization, Pl = 3V T/2 and A2 = 3V3 T2/4, so

(3)

We next observe that each new chain element is one of 12directions in the hexagonal lattice (versus four or eight for thesquare lattice). Thus it is possible to encode transitions withroughly log2 12 bits/transition. Also, for straight line models,it is easy to show that the peak error in encoding is T/2, i.e.,half the lattice size. Thus we arrive at a rate-distortion equa-

527

E[Nc] = 2/(7T)-

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

tion relating bit requirement to error:

be = E[NCI * bits/curve point * peak error

= (2/(rrT)) * log2 12 * (T/2)

= 1.141.

Comparing this result with the best square lattice code, we

see an approximate 1S percent reduction in bit rate for equalpeak error.

This result was obtained by considering a line randomly castupon the lattice and its statistics for a single lattice region.However, assuming that the angle the line makes with respectto the horizontal axis has an irrational tangent, the chain codeprocess is a stationary, ergodic process and it may be claimedthat (4) represents average behavior along the curve as well [ 5 ].

If we are dealing with randomly thrown lines, or slowly curvinglines, such is the case.Notice that E[NC I, the expected number of lattice points in

the chain code per unit length of curve, depends only on Pland A2, where Pl is the perimeter of the triangular quantiza-tion region, and A2 is the area of the triangular fundamentalregion centered on each hexagonal lattice point (i.e., the fun-damental region of the overlayed triangular lattice).This is in fact a general theorem applicable to any shaped

fundamental region, and to any shaped quantization region.Santalo [4] states this theorem in terms of the number ofintersections of a random curve with any line segment ofknown perimeter located in each fundamental region of a

lattice. The theorem holds even for random curves with non-

zero curvature.This theorem allows us to draw some interesting conclusions

about the performance of different quantization regions. Fora given lattice configuration (square, triangular, hexagonal)and lattice size, it is desired to minimize the expected numberof quantized points per curve point, E[Nc]. From above,E[Nc] =Pl/(7r *A2), so we need to minimize P1, since A2is a constant for a given lattice. Therefore, the quantizationregion with the smallest perimeter will always perform the best.This region will always be a generalization of grid-intersectquantization.With the hexagonal lattice chain code, 12 directional transi-

tions are allowable from each lattice point. We now addressthe probabilities of the various transitions. Again assume thecurve to be quantized is a straight line, and draw in the quanti-zation regions of the twelve lattice points surrounding pointA (see Fig. 3)

In general, a transition from any point X to any point Y willoccur if the curve intersects both the quantization region ofX and the quantization region of Y. From geometrical prob-ability theory, the measure of the set of lines intersecting a

region is simply the perimeter of the region.The side of the triangular quantization region is Vr T/2, so

that the measure of the set of lines intersecting the triangularregion is the perimeter of the region, 3 x/Y T/2.

First, we find the probability that point B is chosen, giventhat point A is part of the chain: P(B IA). Letting a and b bethe triangular quantization regions associated with nodes Aand B, respectively [see Fig. 4(a)],

P(BIA) = P(b la).

From probability theory,

P(b Ia) = P(a b)/P(a).

= [P(a) + P(b) - P(a U b)I/P(a)

where P(a rl b) is the probability of intersecting both regiona and region b, and P(a U b) is the probability of intersectinga or b, in other words, intersecting the convex hull of a U b

Fig. 3. Quantization regions of the twelve lattice points closest to latticepoint "A."

B Convex

Hull of

a U b

A

a

(a) (b)Fig. 4. Quantization regions "a" and "b," for computing the A B

transition probability.

[see Fig. 4(b)]. In terms of measures,

P(b Ia) = [p(a) + ,u(b) - ,u(a U b)] /,I(a). (8)

The measures on the right-hand side of the equation are foundby taking perimeters of the regions:

11(a) = Sl(b ) = 3 N/ T/2 .

u(a U b) = T+ 3T. (9)

Thus,

P(b Ia) = (4 - 2 3)/3 = P(BIA). (10)

Actually, this must be divided by two since the parameterizedline has direction, which means half the time the line wouldintersect b before a, giving a B -+ A transition instead of thedesired A -+ B transition. Then

P(A -*B transition) =P(BIA)/2 = (2 - ;3)/3 = 0.089.

(11)

(6) Similarly, the probability of the transition A -* C can be deter-mined:

P(A -+ C transition) = P(c|a)/2 = (2.N§ - 3)/6 = 0.077.

(12)

Finally, the probability of the transition A -+ D:

P(A -+D transition) = (2 - 'T3)/3 = 0.089

which equals P(A -> B).

(13)

(4)

(5)

528

(7)

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

Fig. 5. Three sets of lines for determis inside a quant:

The other nine probabilities can be found from symmOf the 12 possible transitions, three will equal P(A -+ B'will equal P(A -* C), and three will equal P(A -* D). Thprobabilities correctly add to 1.Next, to get the expected length of a transition, E[Lt]

sums the probability of each transition times the length oftransition, over all possible transitions:

12E[Lt] = E P(i) * length (i)

i=1

where each transition has length T, N/XT, or 2T. Then

E[Lt] = T * [12 - 6 ]V--.Now, the expected number of transitions times the expe

length of each transition equals the expected length ofquantized curve. We define Sm to be the ratio of the a(curve length to the expected length of the quantized curvanother measure of quantization performance:

Sm =LcIE[LqI= l/(E[Nc] *E[Lt])= 0.977.

This means that the length of the quantized curve is onlyabout 2.3 percent larger than the actual curve. Again, hexago-nal coding is superior to square lattice chain codes, where thelargest value for Sm is 0.95.Coding of the chain transitions is accomplished by assigning

a digital tag to each transition. Although assigning a 4-bitword for every transition is possible (24 > 12), the efficiencyresulting cancels any intrinsic benefits of the hexagonal lattice.However, by block coding of a sequence of chain transitions,

I Ns

N~~~~~~~~~~~~N

N~~~~~~~~~~~N

I I,N I I

I ~ ~ ~ ~~>1-', ?x x

lining whether a sample curve pointization region.

we can rapidly approach the theoretical limit on performance.For example, by sending three transitions with an 1 -bit word,the number of bits per chain element is 3.67, only slightlylarger than log2 12 = 3.59.

Actually, the probabilities are slightly skewed, admittingthe possibility of further compression via Huffman codes forexample. The one-dimensional entropy given by

12

(14) H = - E Pi log2 Pi = 3.57 bits/transitioni=l

(17)

provides a lower bound on the performance of a source codingscheme, assuming we view the source as memoryless (which ofcourse it is not). Thus we dismiss variable length coding as notbeing worth the additional complexity.Of course, if one exploits the higher dimensional statistics of

the transition process, much lower bit rates are achievable.For example, of the 144 conceivable pairs of suc^essive transi-tions, only 36 are even possible for the hexagonal lattice, againassuming straight-line models. Further, the probabilities of thepossible pairs are skewed. We do not further consider suchschemes in this paper, however.

III. ALGORITHMThe algorithm for hexagonal lattice coding is slightly more

complex than for the square lattice, since the x, y coordinatesof the hexagonal lattice are not evenly spaced, and are notintegers.One needs to determine whether a curve point falls within

the triangular quantization region for a lattice point. To doso, we construct three sets of lines (see Fig. 5).The first (vertical) set is given by equations

529

X=(6 *nl + O* T14 (18)

530 IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

TABLE IHEXAGONAL LATTICE SIMULATION RESULTS

Radius of Nc:Grid curvature #Latt. pts. Bit rate Bit rateSize #Curve #Lattice be be Percent(T) Grid size pts. pts. #Curve pts. Exper. Theory Error

6 7.58 3000 325 0.1083 1.165 1.141 +2.112 3.79 3000 157 0.0523 1.126 1.141 - 1.316 2.08 3000 125 0.0417 1.195 1.141 +4.724 1.89 3000 81 0.027 1.162 1.141 +1.86 1118 122 0.1091 1.174 1.141 +2.96 stochastic 2959 321 0.1085 1.167 1.141 +2.3

where the parameter n 1 is an integer. We find the value of n 1of the line that is closest to the point (x, y) by

n I = round [ (x/(T/4) - 1)/6] . (19)The distance from the point to this line is

dl =abs [x - (6 * nl + 1) * T/41. (20)

Similar processing is done for the second and third sets oflines. The second set has equations

x (6 * n2 + 1) * T/4 (21)where (x', y') is the original coordinate (x, y) rotated by 2ir/3radians. Then, n2 and d2 are found, as in (19) and (20). Simi-larly, for the third set, n3 and d3 are found.Now, the distances are added together:

dist =dl +d2 + d3. (22)

Notice that this distance will equal the height of the triangu-lar quantization region, 3T/4, if the point (x, y) is inside anyquantization region; otherwise, the distance will be greater.This allows determination of whether or not a curve point isclose enough to a lattice point so that the lattice point shouldbe included in the chain code.

If the point is to be included, nl, n2, and n3 can be used todefine which of the 12 possible transitions occured, and thusthe reconstructed point (x, y). Compute Anl, An2, An3 usingnl, n2, n3 from the previous lattice point. If Anl = An2 =An3 = 0, the point is a duplicate, and so no further processingmust be done. Each of the 12 transitions (directions) will havea set of An's associated with it-An 1, An2, and An3 will eachbe either - 1, 0, or 1.To convert these An's to the corresponding (x, y) coordi-

nate, process each differential n in turn.In terms of the differential n's:

Anl=±l: x:=x±T; y:=y;

An2 = ±I: x :=x ± T * cos (2rr/3) =x T T/2;

y :=y ± T * sin (2Qr/3) =y V±/ T/2;An3 = ±1: x :=x ± T * cos (47r/3)=xx T/2;

y ± T * sin (4rr/3)=y +FV T/2.In terms of the absolute n's:

x =nl * (T)+n2 * (-T/2)+n3 *(-T/2)y = n2 * (v'Y T/2) + n3 * (- V T/2).

IV. SIMULATION RESULTSTo test the subjective and quantitative performance of the

hexagonal lattice chain codes, and to compare with squarelattice methods, we programmed the preceding algorithm in

Fortran on a microcomputer. We considered three curvemodels: randomly oriented straight lines, circles with selectablecurvature, and a stochastic curve model which attempts toemulate handwriting or other general line-drawing material.Curves were quantized and statistics taken on the number ofbits per unit length needed to encode the curve. As an option,the original and quantized curves were plotted on a digitalx-y plotter. Similar calculations were done for square lattice,grid-intersect quantization.Sample points along the curve were generated parametrically,

separated by one unit of length. To generate a circle, the angleof each curve element was determined by a first-order differ-ence equation so that the change in angle was a constant, pro-portional to the desired curvature. To create stochastic curves,a second-order difference equation driven by a Gaussian variatewas used, i.e., the change in curvature was normally distributedwith zero mean. The curvature thus exhibited memory, result-ing in smoother curves than a first-order equation would haveprovided. Once the angle was determined, the Ax, Ay requiredfor plotting were then simply the sine and cosine of the angle.

Circles were mainly studied, due to their intrinsic nature ofrepresenting all angles. Sample circles were characterized interms of the ratio of their radius of curvature to the latticeconstant (lattice size). This ratio was varied from about twoto infinity, the latter corresponding to straight lines. It wasassumed that for most applications, the radius of curvaturewould be larger than twice the lattice size, because otherwisequantization error would be excessive.Many circles were produced for each value of curvature,

each having a different orientation with respect to the lattice.Normally, ten circles would be used, with initial angles thatvaried uniformly between 0 and 27r/3 radians, at which pointthe lattice starts repeating. In this way, statistical error,wouldbe minimized.Table I presents the simulation results for hexagonal lattice

quantization. The value of NC (the number of quantized pointsper length of curve) was calculated by dividing the number ofquantized points (hexagonal lattice points in the chain code),by the number of curve points. Then be was determined bymultiplying NC by the number of bits/quantized point (log2 12 =3.585) and by the peak error (T/2), as in (4). Results for bewere compared with the straight-line theoretical value of be=1.141, and percent error (difference) was computed. This er-ror amounted to less than 5 percent for all curvatures studied,showing no significant change with large curvature. Thusstraight line theory was substantiated, and we conclude thatperformance is not affected by curvature as long as the radiusof curvature is larger than two times the grid size.For the square lattice (see Table II), be was similarly com-

puted, the only difference being the number of bits/quantizedpoint, which was changed to log2 8 = 3. The results revealedthat be increased slightly at large curvatures, indicating a smalldegradation in performance.

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

TABLE IISQUARE LATTICE SIMULATION RESULTS

Radius of Nc:Grid curvature #Latt. pts. Bit rate Bit rateSize #Curve #Lattice be be Percent(T) Grid size pts. pts. #Curve pts. Exper. Theory Error

6 7.58 3000 451 0.1503 1.353 1.350 +0.212 3.79 3000 232 0.0773 1.392 1.350 +3.124 1.89 3000 120 0.0400 1.440 1.350 +6.7

Actual curve

Quantized curve

Hexagonal lattice

X-AXIS

Fig. 6. Overlaying a hexagonal lattice for quantization of a circle.

Fig. 6 shows an example of hexagonal lattice quantization ofa circle, with the lattice overlayed. Plots were made of circles(Figs. 7 and 8), straight lines (Figs. 9 and 10), and stochasticcurves (Figs. 11 and 1Z) using both hexagonal and square lat-tices for comparison. These curves were not plotted selectively,but were chosen at random. Grid sizes used for some of theseplots were larger than what would normally be used in a realis-tic application, in order to magnify the effect of quantization.In all cases, the hexagonal lattice quantization has the samepeak error as the square lattice quantization, and has a bit ratethat is 15 percent less. In addition to the quantitative improve-ments cited, a casual evaluation of Figs. 6-12 reveals a markedsubjective preference for the hexagonal scheme as well. Spe-cifically, although the peak errors may be equal with those ofsquare lattice coding, the.average reproduction error is notice-ably smaller.

V. CONCLUSIONS

The hexagonal lattice has been shown to outperform theusual square lattice as a basis for performing chain code quan-tization of line drawings.

The coding efficiency for the hexagonal lattice was calcu-lated theoretically, assuming a generalized grid-intersect quan-tization region, and curves that were randomly oriented straightlines. On a rate-versus-peak-distortion comparison, hexagonalcoding performs about 15 percent better than standard chaincoding, and the actual curve length more nearly equals thequantized curve length.Efficiency was empirically verified by running simulations

using a Fortran computer program. Performance as measuredby be was not degraded when curves with nonzero curvaturewere coded.The quality of the hexagonal lattice quantized curves appears

subjectively better to the eye than the corresponding curvequantized using a standard square lattice. There is a choice of12 directions for each link in the chain, instead of 8 for thesquare lattice, which results in a better fit to a gradual curve.Freeman and Saghri [6], [71 have introduced a generalizedchain code based on a square grid whose qualitative advantagesare along these lines.The algorithm to implement the chain code is slightly more

difficult for the hexagonal lattice, due to the relative complexityof the lattice. The algorithm is straightforward, however, and

531

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

Plot IRadius of Curvature

Grid Size

(a)

(b)

(c)

15.16

7.58

3.79

Fig. 7. Plots of circles quantized using a hexagonal lattice.

Radius of CurvaturePIf1r Grid Size

(a) 15.16

(b) 7.58

(c) 3.79

Fig. 8. Plots of circles quantized using a square lattice.

532

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-5, NO. 5, SEPTEMBER 1983

Fig. 9. Plots of straight lines quantized using a hexagonal lattice. Fig. 12. Plot of a stochastic curve quantized using a square lattice.

ACKNOWLEDGMENTThe authors wish to acknowledge helpful discussions with

J. Koplowitz.

REFERENCES

[11 H. Freeman, "Computer processing of line-drawing data," Comput.Surveys, vol. 6, pp. 57-96, Mar. 1974.

[2] -, Proc. 3rdInt. Congr. Cybern., Namur, Belgium, 1962.[3] J. Koplowitz, "On the performance of chain codes for quantiza-

tion of line drawings," IEEE Trans. Pattern Anal. Machine Intell.,vol. PAMI-3, pp. 180-185, Mar. 1981.

[4] L. A. Santalo, Integral Geometry and Geometric Probability, En-cyclopedia of Mathematics and its Applications. Reading, MA:Addison-Wesley, 1976.

[5] D. L. Neuhoff and K. G. Castor, "A rate and distortion analysis forgrid intersect encoding of line drawings," in Proc. IEEE Comput.Soc. Conf. Pattern Recognition and Image Processing, Aug. 1981.

[6] H. Freeman and J. A. Saghri, "Comparative analysis of line-drawingmodelling schemes," Comput. Graphics Image Processing, vol. 12,pp. 203-223, Mar. 1980.

Fig. 10. Plots of straight lines quantized using a square lattice. [7] J. A. Saghri and H. Freeman, "Analysis of the precision of general-ized chain codes for the representation of planar curves," IEEETrans. Pattern Anal. Machine Intell., vol. PAMI-3, pp. 533-539,Sept. 1981.

Quad-Trees, Oct-Trees, and K-Trees:A Generalized Approach to Recursive Decomposition

of Euclidean Space

CHRIS L. JACKINS AND STEVEN L. TANIMOTO

Abstract-K-trees are developed as a K-dimensional analog of quad-trees and oct-trees. K-trees can be used for modeling K-dimensionaldata. A fast algorithm is given for finding the boundary size of a K-dimensional object represented by a K-tree. For K considered as con-stant; the algorithm provides a method for computing the perimeter of

Fig. 11. Plot of a stochastic curve quantized using a hexagonal lattice.Manuscript received March 18, 1982; revised October 7, 1982.C. L. Jackins resides at 1943 7th Avenue West, Seattle, WA 98119.

the main computations can be coded in less than 15 lines of S. L. Tanimoto is with the Department of Computer Science, Univer-Fortran code. sity of Washington, Seattle, WA 98105.

0162-8828/83/0900-0533$01.00 © 1983 IEEE

533


Recommended