The Quadcode and Its Arithmetic - Tufts Computer Science

22 downloads 0 Views 433KB Size Report
SlJ = sA = 23-3. = 2,. Hence, the distance between A and B is. D,(A, B) = 11 - 4 1 - 1 = 2. D,(A, B) = 16 - 2 1 - 2 = 2. Y. ,. [uly 1987 Volume 30 Number 7.
Image Processing and Computer Vision Robert Haralick Editor

The Quadcode and Its Arithmetic SHU-XIANG LI and MURRAY H. LOEW

ABSTRACT: The quadcode is a hierarchical data structure for describing digital images. It has the following properties: (1) straightfonoard representation of dimension, size, and the relationship between an image and its subsets; (2) explicit description of geometric properties, such as location, distance, and adjacency; and (3) ease of conversion from and to raster representation. The quadcode has applications to computer graphics and image processing because of its ability to focus on selected subsets of the data and to allow utilization of multiple resolutions in different parts of the image. A related approach is the quadtree. Samet recently presented a thorough survey of the literature in that field [7]. Gargantini [2] and Abel and Smith [Z] presented linear quadtrees and linear locational keys that are efficient labeling techniques for quadtrees. In those papers the geometric concepts of the image are discussed by using the tree as an interpretive medium, and the approaches and procedures are based on traversal of the nodes in the tree. In this paper we present the quadcode system, which is a direct description of the image, and discuss the geometric concepts in terms of the coded images themselves. 1. QUADCODE

The quadcode is a quaternary (base-J) code. A quadcode of length n is of the form Q = qlqz, . . . , qn, where qi = 0, 1, 2, 3 for i = 1, 2, . . . , n. When the quadcode is used in describing an image, each character represents one operation of subdividing the image or its subimage into quadrants, as shown and labeled in Figure 1. In many applications (e.g., smoothing, edge detection, shape description) an image is usually subdivided into much smaller units, so the subdividing operation can be repeated recursively many times, until there is no further subdividing needed. Figure 2, on next page, This research was supported in part by the Lady Davis Fellowship Trust 01987

ACM OOOl-0782/87/0700-0621

]uly 1987

Volume 30

$1.50

Number 7

shows the subdividing process and the corresponding quadcodes. A particular quadrant is represented by one of 0, 1, 2, or 3, concatenated to the quadcode of its predecessor, and after each subdividing operation, the length of the quadcode increases by one. As shown in the figure, the quadcode length signifies how many subdividing operations have been done. 1.1 Properties

of the Quadcode

The quadcode length of individual pixels in a z”-by-Z” image is n.

Property 1 (qc length).

The side length of a subimage with quadcode length m in a z”-by-z” image is 2 “-*.

Property 2 (dimension).

Property 3 (area). The area of a subimage with quadcode length m in an image of area A0 is 4-“Ao.

Adding one character to a given quadcode subdivides the given subimage into its quadrants (see Figure 3, on next page).

Property 4 (subdividing).

Property 5 (merging). If four quadcodes of length i have the first i - 1 positions the same, they represent the

four quadrants of the same subimage, which is represented by the (i - I)-position quadcode (Figure 3). A subimage can be located in an image according to each position of its quadcode, which is equivalent to subdivision of the initial image (see Figure 4, p. 623).

Property 6 (locating).

0

1

2

3

ti FIGURE1. Quadcodes and Quadrants

Communications of the ACM

621

ResearchContributions Property 7 (conversion).

Write the quadcode and array labels i and j of a pixel in a 2”-by-2” image (i and j are supposed to be from 0 to 2” - 1) into binary form; it can be proved [3] that 9142,

q.

. ..f

=

iljli2j2,

. . . , injn

TABLE I. Quadcodes in Binay (iljli2j2) and Quaternary (qlq2) Forms iljii2j2

9x92 . . I?12

(1)

or

ili2

i=

i

00

(qkDIV2)x2”-k

j = kE, (qkMOD 2) x 2”-k Q = k$, (2ik +

jk]

01 10

x 4"-k.

(3)

h-r Eqs. (l)-(3), qk, ik, and jk (k = 1, . . . , n) represent the kth position of the quadcode and the array labels i and j, respectively. The equations show that the array labels i and j are the same as the two binary numbers that compose the odd and even bits of the quadcode when

01

10

11

0000

0001 01 0011 03 1001 21 1011 23

0100 10 0110 12

0101 11

00 0010 02 1000 20 1010 22

k=l

@I

00

11

1100 30 1110 32

0111 13 1101 31 1111 33

written in binary. This is represented in Table I where the two axes are array labels (or coordinates) i and j; the entries give the corresponding quadcodes in both binary and quaternary forms.

l2 --Ot

3

2

3 1

0

1

1

0

1

0

2

3

2

-2

3-

0

3

20

1

2

t-H

3

2

21

3

22

64

3

23

lb) FIGURE2. Subdividing and Quadcode Representation

Subdividing

q,....,qi

>

qi,...,q,o

F-l qr,...,qi2

q1.. . . , qi1

Bl qr,...,q;3

FIGURE3. Subdiiiding and Merging

622

Communicationsof the ACM

Iuly 1987 Volume 30 Number 7

Research Contributions

size of elementary square A is 23-2 by 23-2 (i.e., 2 by 2) and the size of B is 23-3 by 23-3 (i.e., 1 by 1). 2.2 Location

If we know the size of a given elementary square, we can locate it by the coordinates of one of the characteristic points in the square. We choose the upper left corner point as the characteristic point. Then, from eq. (2), we derive the following: x=:

(qkMOD2)x2”-k

‘I

k=, .-

(4)

y = k;l (qk DIV 2) x 2"-k. For example, the locations of the squares A = 12 and B = 221 in Figure 5 are x(A) = ; (qAk MOD 2) X 23-k = 4 k=l

y(A) = i: (q,z,kDIV 2) X 23-k = 2 k=l

El

and

3

31

x(B) = ; (qakMOD 2) X Z3-’ = 1

312

k=l

FIGURE4. Locating a Subimage Using Quadcode

y(B) = 5: (qak DIV 2) X 23-k = 6. k=l

2. ANALYSIS

OF ELEMENTARY

2.1 Elementary

SQUARES

Squares

When a quadcode can represent a subset of an image, we call the subset an elementary square. For example, in Figure 5 there are two elementary squares, and their quadcodes are A = 12 and B = 221. In general, an elementary square in a z”-by-2” image can be represented by q,, ...I q,, where m 5 n. The size of an elementary square with quadcode length m is z”+ by Znmrn.For instance, in Figure 5 the

l4TF-m

2.3 Separation

The separation between two elementary squares A and B is composed of the smallest distances between any points on the boundaries of the two elementary squares in both the horizontal and vertical directions, and they are calculated by

DAA, Bl = Ix(B) - x(A)1 D&L B) =

SL

(5)

ly(B) - y(A)1 - Su-

where SLis the horizontal side length of the leftmost of the two elementary squares A and B, and Su is the vertical side length of the uppermost of the elementary square. Because the quadcodes of A and B give their dimensions and their horizontal and vertical locations, both SLand So can be obtained from their quadcodes. For example, in Figure 5, A = 12 and B = 221; the leftmost elementary square is B, and the uppermost 2 is A. Then, x(A) = 4

y(A) = 2

x(B) = 1 sL

=

se

Y(B) = 6 =

23-3

=

1

SlJ=

sA

=

23-3

=

2,

Hence, the distance between A and B is D,(A, B) = 11 - 4 1 - 1 = 2 D,(A, B) = 16 - 2 1 - 2 = 2 FIGURE5. Location and Separation

[uly 1987

Volume 30

Number 7

,

Y

as shown in Figure 5.

Communications of the ACM

623

ResearchContributions

2.4 Adjacency The detection of connectivity is a basic and important subject in image analysis. THEOREM 1. The general condition of adjacency for elementary squares is the following:

D,(A, B) x D,,(A, B) = 0 D,(A, B) + D,(A, B) 5 0

(6)

PROOF. If D,(A, B) = 0, then D,(A, B) 5 0. According to the first part of eq. (5) D,(A, B) = 0 means that the right side of the far left square is collinear with the left side of the far right square. And, according to the second part of (5) D,(A, B) zz 0 means that either the upper left corner of the far right square is on the right side of the far left square (see “a” of Figure 6), or the upper right corner of the far left square is on the left side of the far right square (see “b” of Figure 6). If D,(A, B) = 0, then D,(A, B) 5 0, and the proof is the same. 0 In Figure 7 there are three elementary squares A = 1, B = 221, and C = 310. According to eq. (5), the separations among them are D,(A, B) = 2

D,(A, C) = -2

D,(B, C) = 4

D,(A, B) = 2

D,(A, C) = 0

D,(B, Cl = 1,

D,(B, C) x D,(B, C) = 4

and

FIGURE7. Examples for the Definition of Adjacency as Expressed in Equation (6)

and adjacency condition (eq. (6)) becomes

n-4 I I or

- x(P~) I3 I Y(Pz) - Y(P~) I1 = 1

I X(Pz) - X(Pl) I + I Y(P2) - Y(P1)I = 1.

(8)

3. REGION

REPRESENTATION

AND

ANALYSIS

3.1 Region Representation

D&4, C) x &(A, C) = 0,

D,(A, C) + D,(A, C) = -2.

In view of eq. (6). we observe that elementary squares A and C are adjacent, but A and B and B and C are not, as shown in Figure 7. Equation (6) is the general adjacency condition for elementary squares of any size. For the connectivity detection of pixels, SL= So = 1, the separation equation (eq. (5)) becomes MPI,

PZ) = I NPZ) - x(p11 I - 1

&(PI, PZ) = I Y(PZ) - Y(PI) I - 1

FIGURE6. Examples for the Definition of Separation as Expressed in Equation (5)

624

B

Equations (5) and (6) can be extended to detect the connectivity of elongated regions, if we know their locations (still represented by the coordinates of their upper left corner points) and the lengths of their sides.

so IMA, Bl x D,(A, Bl = 4,

C

Communicationsof the ACM

(71

In quadcode representation, a region is represented as a set of quadcodes R = IQnl

n=l,...,N,

(9)

where each element represents an elementary square in region R, and N is the total number of those elementary squares in region R. For example, the region in Figure 8 can be represented as R = 103, 120, 121, 21, 230, 231, 300, 301, 320, 321).

FIGURE6. Quadcode Set of a Region

\uly 1987 Volume 30 Number 7

ResearchContributions

3.2 Set Arithmetic

for Quadcodes

Suppose A and B are the quadcodes of two elementary squares A= al, . . . . ak B = bl, . . . . b, and k 5 m. THEOREM 2. The intersection of two such quadcodes is either empty or the longer quadcode: al, . . . , ak fl

b,,...,b,

krm

b1, . . . . b, 0

=

if a, ,..., otherwise.

ak=bj

,...,

bk

WI

PROOF.

(1) a1,..., ak=bl ,..., bk B = b,, . . . , b, = al, . . . , akbk+l, . . , b, C al, . . . , ak = A (2) a,, . . . . ak#bl, . . . . bk

0

The union of two such quadcodes is either their concatenation or the shorter quadcode: THEOREM 3.

=

aly...pak

ia,, . . . , ak, b,, . . . , b,)

if Ill ,... vUk=bl,..., othenuise.

bk

The proof is the same as for Theorem 2. Cl

PROOF.

The laws of set arithmetic are true for quadcode sets too, and they include the commutative, associative, and distributive laws, as well as de Morgan’s law. 3.3 Union and Intersection Definition. The union of two regions is represented by the union of the sets of the two regions.

For example, in Figure 9 there are two regions: A= (12,211, 3)

and

B = {03,1,21,310).

The union of A and B, according to eq. (lo), is A U B = (12, 211, 31 U (03, 1, 21, 310) = (03, 1 u 12, 21 u 211, 3 u 310) = (03, 1, 21, 31.

The intersection of two regions is represented by the intersection of the sets of the two regions. Definition.

According to eq. (9),

0

A

B

FIGURE9. Union and Intersection

According to the definition of the quadcode, al, . . . , ak n b,, . . . , bk = 0 and b,, . . . , b, C bl, . . . , bk

El 4. CONCLUSIONS

In this paper we introduced the quadcode system, discussed its geometric properties, analyzed the geometric concepts of elementary squares, and presented the quadcode set representation of regions. From our discussion we see that the information-compact and intrinsic hierarchical characteristics of the quadcode benefit the representations and analysis by making them more intuitive and computable. The quadcode can also be used in a tree-structured representation. In earlier work [4, 51 we discussed the quadcode-labeled tree (the qc-tree), storage efficiency [5], and applications of the qc-tree, such as boundary search [4]. Instead of using a tree as the interpretive mediumtransferring an image into the tree, performing the processing by traverse and search of the tree, and then transferring back to the image-this paper discussed opportunities and methods for analysis directly on the coded image. In a companion paper [6], we discuss adjacency detection and perform all the computations in terms of quadcodes. The properties and the results presented here for two-dimensional images can be extended to threedimensional images, where the octcode combines the coordinates of three dimensions into one code. In binary form, each position of the octcode is composed of, respectively, z, y, and x coordinate Oi

= ZiyiXi.

The so-constructed octcode is also an intrinsically archical coding system.

hier-

A f-l B = 112, 211, 3) I-l (03, 1, 21, 3101 = {I n 12, 21 n 211, 3 n 310) = 112, 211, 3101,

as shown in Figure 9.

Iuly 1987 Volume 30 Number 7

REFERENCES 1. Abel, D.J., and Smith, J.L. A data structure and algorithm based on a &ear key for a rectangle retrieval problem. Comput. Graph. Image Process.24, 1 (Oct. 1983). l-13. 2. Gargantini. I. An effective way to represent quadtrees. Commun. ACh4 25, 12 (Dec. 1982), 905-910.

Communicationsof the ACM

625

Research Contributions

3. Li. S.X., and Loew, M.H. Quadcodes and their application in image processing. GWU/IIST Rep. 83-15, Dept. of Electrical Engineering and Computer Science, George Washington Univ., Washington, D.C., Oct. 1983. 4. Li. S.X., and Loew. M.H. Boundarv chain codes from auadcode trees. In Proceedingsof the IEEE 1984 Computer Vision Confertke (Annapolis, Md.. Mar.). IEEE Press, New York, 1984, pp. 178-182. Li, S.X., and Loew, M.H. The quadcode and its application. In Proceedingsof the 7th lnternationnl Conferenceon Pattern Recognition (Montreal, Canada, July JO-Aug. 2). IEEE Press, New York, 1984. pp. 227-229. Li. S.X.. and Loew, M.H. Adjacency detection using quadcodes. GWLJ/IIST Rep. 84-52, Dept. of Electrical Engineering and Computer Science, George Washington Univ., Washington, D.C., Dec. 1984 (also in this issue of Communications). Samet, H. The quadtree and related hierarchical data structures. ACM Cornput. Sum 16. 2 (rune 1984), 187-260.

General Terms: Algorithms, Performance, Theory Key Words and Phrases: Operations on encoded images, parallelism, pyramids Additional

Received

10/85, 11/86; accepted 2/w

Authors’ Present Addresses: Shu-Xiang Li, Dept. of Automatic Control, Changsha Institute of Technology, Changsha City, Hunan Province, China; Murray H. Loew. Dept. of Electrical Engineering and Computer Science, George Washington University, Washington, DC 20052 (currently on leave at the Dept. of Electrical Engineering, Technion71srael Institute of Technology, Haifa 32000. Israel).

Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission.

CR Categories and Subject Descriptors: E.1 [Data]: Data Structurestrees; 1.3.5 [Computer Graphics]: Computational Geometry and Object Modeling-hierarchy and geometric transformations; 1.4.2 [Image Processing]: Compression (coding)-exact coding: 1.4.6[Image Processing]: Seg-

mentation-pixel

3/W revised

classification; partitioning

ACM SPECIALINTERESTGROUPS SIGCAPH Newsletter

ARE YOUR TECHNICAL INTERESTS’HERE?

Physically

The ACM special Intereat Groups further the & vancementofcomputersciencearKlpracticein

(Computers

Handicapped)

and the

Print

Edition

SIGCAPH Newsletter.

Cassette

SIGCAPH Newsletter,

Print and Cassette

Editions manyspeciakedareas.hAemhs of eachSIG receiveasmeoftheirbenefitsapt3icdMexSIGCAS Newsletter (Computers duaiveiydevotedto the specialitltewt. ThefolSociety] lowlngarethepubllcatis thatareavailablemrougllmembershiQorspedalsubscription. SIGCHI Bulletin (Computer and

Edition

Computer

Review SIGACT NEWS (Automata Computability Theory)

and

Human

(Computer

Personnel

Computer

Architecture

of Computer

SIGART Newsletter Intelligence) SIGBDP DATABASE Processing) SIGBIO Newsletter

SIGCUE Bulletin

Science

(Computer

Uses in

Education)

SIGDA Newsletter

Data

Newsletter

(Design

Automation)

SIGDOC Asterisk (Systems Documentation)

(Biomedical

SIGIR Forum (Information

of the ACM

of Data]

(Numerical

Mathematics)

SIGOIS Newsletter Systems)

(Office Information

SIGOPS Operating Systems Review (Operating Systems)

SIGPLAN

FORTRAN

Retrieval]

FORUM (FORTRAN) (Security.

Audit.

and Control)

SIGSAM Bulletin Manipulation] SIGSIM Simuletter Modeling)

SIGGRAPH Computer Graphics (Computer Graphics)

Computing)

Communications

News

Systems)

(Artificial

(Business

(Computer

Education)

SIGAPL Quote Quad (APL)

(Architecture

SIGNUM

SIGSAC Newsletter SIGCSE Bulletin

SIGARCH

SIGMICRO Newsletter (Microprogramming)

SIGPLAN Notices (Programming Languages)

(Data Communication)

Letters (Ada)

SIG&la

626

Communication

and SIGCPR Newsletter Research)

Evaluation and

SIGMOD Record (Management

Interaction) SIGCOMM

SIGMETRICS Performance Review (Measurement Evaluation)

(Symbolic and Algebraic (Simulation

and

SIGSMALL/PC Newsletter (Small and Personal Computing Systems and Applications) SIGSOFT Software Engineering (Software Engineering)

Notes

SIGUCCS Newsletter (University College Computing Services)

and

luly 1987

Volume 30

Number 7

Suggest Documents