Gis - 4
Gis - 4
Procedure
begin by dividing the array into four 8x8 quadrants, and
numbering them 0, 1, 2 and 3 as in the Morton order quads 1,
2 and 3 are homogeneous (all A) quad 0 is not homogeneous,
so we divide only it into four 4x4 quads these are numbered
00, 01, 02 and 03 because they are partitions of the 8x8 quad
0 of these, 00, 01 and 02 are homogeneous, but 03 is divided
again into 030, 031, 032 and 033 now only 031 is not
homogeneous, so it is divided again into 0310, 0311, 0312
and 0313
what we have done is to recursively subdivide using a rule of
4 until either: a square is homogeneous or
Decoding locations
the conversion to row and column is the same as for
decoding Morton numbers except that in this case the
code is in base 4 in the example the lone B pixel is
assigned code 0311
1. convert the code to base 2
hint: every base 4 digit converts to a pair of base
2 digits
thus 0311 becomes 00110101
2. separate the bits to get:
row 0100 = 4
column 0111 = 7
so the numbering system is just the Morton numbering of
blocks, expressed in base 4
however, sequence and data compression are not the
most useful aspects of this concept
C. THE QUADTREE
can express this sequencing as a tree the top is the entire
array at each level there is a four-way branching each
branch terminates at a homogeneous block
the term quadtree is used because it is based on a rule of
4 each of the terminal branches in the tree (the ones
having values) is known as a leaf in this case there are 13
leafs or homogeneous square blocks
Coding quadtrees
to store this tree in memory, need to decide what to store
in each memory location
there are many ways of storing quadtrees, but they
all share the same basic ideas
one way is to store in each memory location
EITHER: 1. the value of the block (e.g. A or B), or or
2. a pointer to the first of the four "daughter" blocks
at the next level down
all four daughter blocks of any parent always occur
together overhead - Coding quadtrees
thus, the quadtree might be stored in memory as:
Position: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Contents: 2 6 A A A A A A 10 A 14 A A A B A A
0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4):level(
the content of position 1 is a pointer indicating that the map is subdivided into four blocks
whose contents can be found starting at position 2 position 2 indicates that the four
parts of the 0 block can be found beginning at position 6 positions 3, 4 and 5 indicate
that the other three level 1 blocks are all A and are not further subdivided
Accessing data through a quadtree
consider two ways in which this quadtree may be accessed:
1. find all parts of the map with a given value
2. determine the contents of a given pixel
notation: if the array has 2n by 2n pixels there are n possible levels in the tree, or n+1 if we
count the top level (level 0) use m for the number of leafs
6
1. to find the parts of a map with a given value we must examine every leaf to see if
its value matches the one required this requires m steps as there are m leafs
2. to find the contents of a given pixel, start at the top of the tree if the entire map is
homogeneous, stop as the contents of the pixel are known already if not, follow the
branch containing the pixel do know which branch to follow: take the row and column
numbers, write them in binary, interleave the bits, and convert to base 4 e.g. row 4,
column 7 converts to 0311 at each level, use the appropriate digit to determine which
branch to follow e.g. for 0311, at level 0 follow branch 0, at level 1 follow branch 3,
etc. in the worst case, may have to go to level n to find the contents of the pixel, so
the number of steps will be n
10