Pattern Recognition, Vol. 31, No. 3, pp, 327 332, 1998 : ( 1997 Pattern Recognition Society. Published by Elsevier Science Ltd Printed in Great Britain. All rights reserved 0031 3203/98517.00 + .00
Pergamon
PII: S0031-3203(97)00051-4
LEVEL COMPRESSION-BASED IMAGE REPRESENTATION AND ITS APPLICATIONS K U O - L I A N G C H U N G * and K U O - B A O H O N G Department of Information Management, National Taiwan University of Science and Technology, No. 43, Section 4, Keelung Road, Taipei, Taiwan 10672, R.O.C. (Received 5 September 1996; accepted 7 May 19971
Abstract --In this paper, a level compression-based image representation (LCBIR) is presented. This new image representation method improves the bintree representation for compressing digital binary images. Then we present a fast search algorithm on the LCBIR, which can support fast search and query in pictorial database. Experimental results show that our search algorithm on the LCBIR is faster than the one on the bintree representation. Spatial data structures Bintree Image compression Search algorithm Pictorial database
demonstrate the advantages of our search algorithm and space utilization on the LCBIR when compared to those on the bintree representation.
l. INTRODUCTION Representing and manipulating binary images are two important issues in image processing, pattern recognition, pictorial database, computer graphics, etc. Hierarchical data structures 11'21are widely used to represent digital binary images. Among these spatial data structures, bintree ~a~ and quadtree ~4~ are two well-known storage-saving image representations and they can be implemented by pointer-type data structures. Previously, Kuzmin ~sl presented an adaptive bintree to make the bintree structure more balanced. In this research, we focus on improving the bintree image representation although it can be applied to improve the quadtree and octree image representations. ~1'21 In this paper, a level compression-based image representation (LCBIR) is presented. This new image representation improves the bintree representation for compressing digital binary images. Then we present a fast search algorithm on the LCBIR, which can support fast search and query in pictorial database. Experimental results show that our search algorithm on the LCBIR is faster than the one on the bintree representation. The remainder of this paper is organized as follows. In Section 2, the LCBIR is presented. In Section 3, we first take two examples to demonstrate the concept of our search algorithm on the LCBIR, then the formal search algorithm is given. In Section 4, some experimentations on real images are carried out to
*Author to whom correspondence should be addressed. E-mail:
[email protected]. This research was supported in part by the National Science Council of R.O.C. under contracts NSC86- 2213-E0I 1-010 and NCHC86-08-015.
Level compression
2. LEVEL COMPRESSION-BASED IMAGE REPRESENTATION In this section, we first introduce the bintree, then the proposed LCBIR to improve the bintree representation is presented. The bintree is a hierarchical data structure for representing binary images. It is based on the recursive further subdivision of a bounded image array into two equal-sized parts. At each step, the splitting is alternated between the x and y - axes. If the array does not consist entirely of l's or entirely of O's, it is further subdivided into two equal-sized parts until blocks that consist entirely of l's or entirely of O's are obtained. An image example and its corresponding bintree are shown in Fig. 1. Let the root node in the bintree be at level 0. In Fig. l(b), it is observed that the subtree rooted at the root node (at node a), ranging from level 0 (3) to level 3 (5), is a complete binary tree. Figure 1 (b) can be reduced to Fig. 2, where the highest three levels in the bintree of Fig. l(b) is replaced by a single node of degree 8 = 23; the subtree rooted at node a, ranging from level 3 to level 4, is replaced by a single node of degree 4 = 22. These replacements are made in a t o p - d o w n manner. After doing these level-compressions, the number of nodes in Fig. l(b) is reduced from 29 to 21, where 21 is the number of nodes in Fig. 2. Consider a real image as shown in Fig. 3. It is obvious that the highest four levels in the corresponding bintree is a complete binary tree. Hence, we replace the highest three levels in the bintree with a single node of degree 8. Previously, the concept of level-compressions was ever used in the LC-trie data structure/61
327
328
KUO-LIANG CHUNG and KUO-BAO HONG
mm mm nmmm mmmm mm mm
m mm m m mm mm
(a) Binary image.
(b) Bintree structure. Fig. 1. A binary image and its corresponding bintree. (a) Binary image. (bl Bintree structure.
1
0
19 20 Fig. 2. The level compression-based bintree for Fig. l(b).
To the best of our knowledge, it is the first time that this concept is used to improve the bintree image representation. As a result, a faster search algorithm is derived when a regioncode is given. The above LCBIR can be implemented efficiently by using the array data structure. Each entry, which denotes the node index in the LCBIR, in the array has three fields, namely, the branch, the pointer, and the color. For example, the entries in the array are addressed by 0, 1, 2 . . . . . 20 logically, respectively, with respect to the node-indices in Fig. 2. If the entry is corresponding to a leaf node in the LCBIR, the value of its branch is set to be 0; otherwise, the value of its branch is set to be i, where 21 is the number of children for that node. For example, node 6 in Fig. 2 has four children, so the value of its branch is 2. Since node 3 (2) is a black (white) leaf node, the color of that node
Fig. 3. The Taiwan image.
is set to be 1 (0) and the branches of both nodes are set to be O's. The array representation for Fig. 2 is shown in Table 1. The value of the pointer in Table 1 denotes the logical address of its leftmost child when it is an internal node; otherwise, it denotes the logical address to point to some attributes of that leaf.
329
Level compression-based image representation and its applications Table 1. Array representation for Fig. 2 Entry
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Branch Pointer Color
3 1
1 9
0
0
1 11
0
2 13
0
1 17
0
0
0
0
1 19
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
1
0
1
0
1
l
3. THE SEARCH ALGORITHM
Given a regioncode stored in an array, following the definitions, ~7'8~ the search algorithm in the LCBIR is to find a path from the root to the leaf such that the traversed edges match the regioncode. We then output the color of the leaf node. In fact, the color can be associated with other attributes. If the given regioncode dose not correspond to a leaf node, we return the value "GRAY". We take two examples to demonstrate the basic concept of our search algorithm on the LCBIR, then a formal search algorithm is given. In the next section, we evaluate the performance between the search algorithm in the bintree and ours. As the first example, consider the regioncode 0111. Two variables, namely, table_ptr and regiol~ptr, are used in our demonstration. The variable table_ptr (region_ptr) points to the current entry (position) in Table 1 (the regioncode). Initially, table_ptr and region_ptr point to the first element in Table 1 and the regioncode, respectively. That is, we start at the root node of Fig. 2, i.e., entry 0 in Table 1. The value of its branch in Table 1 is 3, then we extract the first three bits from the regioncode and we have the value 3 ( = 011). Thus, table_ptr is now at entry 4 ( = 3 ÷ 1) as shown in Table 2; region ptr is increased by 3 to point to the fourth position in the regioncode. At entry 4 in Table 2, the corresponding branch is 1, then we extract the fourth bit from the regioncode and we have value 1. Thus, table_ptr is now at entry 12 ( = 1 + 11) as shown in Table 3. Since entry 12 has branch value 0, it is a leaf node and its color is white.
Fig. 4. A chessboard image.
As described above, the degree of an internal node in the L C B I R is always 2 i for i > 0 and the branch value is i which takes [-log/] bits, where log is with base 2. It is clear that if the original bintree has n leaves, [-log log n l bits are sufficient to represent the branch value of each node in the LCBIR. F o r example, a 28 x 2 s binary image, 4 ( = log log 216) bits will suffice for representing each branch value. The best case for the LCBIR, of course, is the chessboard image as shown in Fig. 4. The number of nodes in the corresponding bintree is 31 while the number of nodes in the L C B I R is 17. In the worst case, where there is no level compression occurred, the number of nodes required in the LCBIR is the same as that in the bintree. Since in most cases L C B I R has shorter depth when compared to the bintree, a faster search algorithm can be derived as shown in the next section.
Table 2 Entry
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Branch Pointer Color
3 1
1 9
0
0
1 11
0
2 13
0
1 17
0
0
0
0
1 19
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
I
0
I
0
1
1
Table 3 Entry
0
I
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Branch Pointer Color
3 1
1 9
0
0
1 11
0
2 13
0
1 17
0
0
0
0
1 19
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
1
0
1
0
1
1
KUO-LIANG CHUNG and KUO-BAO HONG
330
Table 4 Entry
0
l
2
3
4
5
6
7
8
9
l0
11
12
13
14
15
16
17
18
19
20
Branch Pointer Color
3 1
1 9
0
0
1 11
0
2 13
0
1 17
0
0
0
0
1 19
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
1
0
1
0
1
1
Table 5 Entry
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Branch Pointer Color
3 1
1 9
0
0
1 11
0
2 13
0
1 17
0
0
0
0
l 19
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
l
0
1
0
1
1
As a second example, consider the regioncode 10,100. Using the same procedure described above, we first start at entry 0 and extract the first three bits from the given regioncode and we have the value 5 ( = 101). Thus, table_ptr is now at entry 6 ( -- 5 + 1) as shown in Table 4; region_ptr is increased by 3 to point to the fourth position in the regioncode. Since the branch value in entry 6 is 2, we extract the next two bits, which have value 0. Thus, we arrive at entry 13 and region_ptr is increased by 2 to point to the sixth bit. At entry 13, the branch value is 1. However, there is no bit to be extracted from the given regioncode because the region_ptr is greater than the length of the regioncode. Since node 13 of Fig. 2 is an internal node, " G R A Y " is returned. The final status is shown in Table 5. Our detailed search algorithm is shown below. Algorithm search
Input: regioncode [ ]: array of bits region_len: the length of the given regioncode LCBIR: array representation for LCBIR
if LCBIR [node].branch = 0 return L C B I R [node].color else return GRAY; end procedure EXTRACT(S, k, m) begin return the number denoted by the successive m bits starting at position k in S; end
4. EXPERIMENTATIONS In order to evaluate the space requirements for the bintree representation and our LCBIR, some experimentations are included. We first compare the storage requirements in PC implementation using C language for each node in the L C B I R and bintree, respectively. Each node in the bintree contains two pointers, each pointer needs three bytes since the original binary image is of 28 x 28; it takes one byte to store the color.
Output: If the given regioncode denotes an internal node in the corresponding LCB1R, then return 'GRAY'. If the given regioncode denotes a leaf node in the LCBIR, then return its color or its corresponding information which inherits from that node. procedure Search(LCBIR, regioncode, regionlen) begin region_ptr = 0; node = 0; while(LCBIR [node].branch > 0 and region_ptr < = region_len) begin node = L C B I R [node].pointer + EXTRACT(regioncode, regior~ptr, L C B I R [node].branch); region_ptr = regior~ptr + L C B I R [nodeJ.branch end
Fig. 5. The Taiwan map.
Level compression-based image representation and its applications
Fig. 6. The floodplain map.
Table 6. Space requirements comparison Structure
Taiwan map
Floodplain map
Bintree LCBIR Ratio
2035 nodes 1713 nodes 0.481
3443 nodes 2739 nodes 0.455
331
Hence, a bintree with n nodes needs about 7n bytes. Since in the LCBIR, each branch value takes 4 ( -- log log 216 ) bits only, we can combine the branch value and the color value into one byte in practice. Hence, a L C B I R with n nodes needs about 4n bytes. Experimentations have been carried out on a PC DX-486 computer and we take two real maps as shown in Figs. 5 and 6, respectively, to evaluate the costs search algorithm on the bintree and the one on the LCBIR. Both real images are of resolution 28 x 28. The experimental results are shown in Table 6, where "ratio" is the product of 7 and the number of nodes required for bintree over the product of 4 and the number of nodes required for LCBIR since we see that each node needs 7 bytes in the bintree; each node needs 4 bytes in the LCBIR. It is observed that for the Taiwan (floodplain) map, the LCBIR representation has about 52% (54%) space utilization improvement over the bintree representation. We also evaluate the costs of search algorithms on the bintree and LCBIR representations. Nine files of regioncodes with 10,000, 20,000 . . . . . 90,000 regioncodes, respectively, are generated and each regioncode with the length ranging from 1 to 16 is randomly generated. The experimental results are shown in Tables 7 and 8, respectively, for the Taiwan map and the floodplain map, where the search time is counted by using the time unit " T I C K " (a " T I C K " denotes 0.55 s). It is observed that for the Taiwan (floodplain) map, the search algorithm on the LCBIR representation
Table 7. Search costs for the Taiwan map The size of the regioncodes 10,000 20,000 30,000 40,000 50,000 60,000 70,000 80,000 90,000
BINTREE
LCBIR
Ratio
Search time
Average depth
Search time
Average depth
14 28 42 56 69 84 97 111 125
4.899000 4.891800 4.883033 4.883025 4.871580 4.866650 4.870643 4.868650 4.868267
10 20 30 40 50 60 70 80 90
2.463800 2.455650 2.449700 2.452825 2.444920 2.441567 2.442329 2.441950 2.442622
0.714 0.714 0.714 0.714 0.725 0.714 0.722 0.721 0.720
Table 8. Search costs for the floodplain map The size of the regioncodes 10,000 20,000 30,000 40,000 50,000 60,000 70,000 80,000 90,000
BINTREE
LCBIR
Ratio
Search time
Average depth
Search time
Average depth
13 27 39 52 66 79 91 104 120
4.577900 4.543500 4.533533 4.542575 4.539480 4.545167 4.546457 4.550388 4.549478
10 19 30 39 49 59 70 80 89
2.446000 2.432550 2.424033 2.426075 2.424560 2.427000 2.427529 2.428000 2.428000
0.769 0.704 0.769 0.750 0.742 0.747 0.769 0.769 0.742
332
KUO-LIANG CHUNG and KUO-BAO HONG
has about 28% (25%) speed improvement over the search algorithm on the bintree representation.
5. CONCLUSION We have presented the proposed LCBIR representation which improves the well-known bintree image representation33~ In fact, our result also can be applied to improve the quadtree and octree image representations. In addition, a fast search algorithm, which can support quick query in the pictorial database, has been presented. Experimental results show that our search algorithm on the LCBIR has better performance when compared to the one on the bintree structure.
REFERENCES
2. H. Samet, Design and Analysis of Spatial Data Structures, Addison Wesley, New York (1990). 3. K. Knowlton, Progressive transmission of gray--scale and binary pictures by simple, efficient, and lossless encoding schemes, Proc. IEEE 68, 885-896 (1980). 4. G. M. Hunter and K. Steiglitz, Operations on images using quad trees, IEEE Trans. Pattern Analysis Mach. IntelL 1(2), 145 153 (1979). 5. E. Kuzminn, Reduction of space-complexity of hierarchical data structures, Int. J. Imayiny Systems Technol. 4, 3-6 (1992). 6. A. Andersson ans S. Nillsson, Improved behaviour of tries by adaptive branching, Inform. Process. Lett. 46, 295-300 (1993). 7. K. L. Chung and C. J. Wu, A fast search algorithm on modified S-trees, Pattern Recognition Lett. 16, I 159-1164 (1995). 8. W.D. Jonge, A. S. Tanenbaum and R. P. van de Riet, Two access methods using compact binary trees, IEEE Trans. Software Eny 13, 799-809 (1987).
1. H. Samet, Applications of Spatial Data Structures, Addison Wesley, New York (1990).
About the Author--KUO-LIANG CHUNG received the B.S., M.S., and Ph.D. degrees in Computer
Science and Information Engineering from National Taiwan University of R.O.C. Since 1995, he has been a professor in the Department of Information Management of the National Taiwan Institute of Technology. From 1984 to 1986, he went soldiering for military service. His current research interests include image processing & pattern recognition, computer graphics & computational geometry, data & image compression, and high speed computing. Dr. Chung has authored more than 55 papers in refereed international well-known journals. He has received the Outstanding Paper Award from the Computer Society of R.O.C. in 1990 and the Outstanding Research Awards from the National Science Council of R.O.C. in 1992 and 1994, respectively. In 1995, he received the National Taiwan Institute of Technology Teaching Excellence Award. Since 1996, he has been the executive editor of Journal of the Chinese Institute of Engineers. He is a member of ACM, IAPR, IEEE, and SIAM. KUO-BAO HONG received the B.S. degree in Electronical Engineering from National Taiwan Institute of Technology of R.O.C.; received the M.S. degree in information Management from the same institute. His current research interests include virtual reality, image processing, and spatial data structures. About the Author