Quad Trees
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 1114 | Accepted: 537 |
Description
A binary image, such as the one shown in Figure 2(a), is usually represented as an array of binary entries, i.e., each entry of the array has value 0 or 1. Figure 2(b) shows the array that represents the binary image in Figure 2(a). To store the binary image of Figure 2(b), the so-called quad tree partition is usually used. For an N * N array,N <= 512 and N = 2i for some positive integer i, if the entries do not have the same value, then it is partitioned into four N/2 * N/2 arrays, as shown in Figure 2(c). If an N/2*N/2 array does not have the same binary value, such as the upper right and
lower right N/2*N/2 arrays in Figure 2(c), then we can divide it into four N/4*N/4 arrays again. These N/4*N/4 arrays in turn can also, if needed, be divided into four N/8 * N/8 arrays, etc.. The quad tree partition is completed when the whole array
is partitioned into arrays of various size in which each array contains only one binary value. Figure 2(c) contains the arrays after the quad tree partition is completed.
Instead of storing the binary image of Figure 2(a), we only need to store the quad tree in the form as Figure 2(d) which is encoded from Figure 2(c). In Figure