Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a QuadTree work for non-square areas?

I understand how quad trees work on square images (by splitting the image until the section is a single colour, which is stored in the leaf node).

What happens if the image has one dimension longer that the other, you may end up with a 2x1 pixel area as the smallest sub unit, making it difficult to use quadtree division methods to store a single colour. How would you solve this issue?

like image 855
user559142 Avatar asked Feb 13 '11 16:02

user559142


People also ask

How does a quadtree work?

A quadtree is a tree data structure in which each internal node has exactly four children. Quadtrees are the two-dimensional analog of octrees and are most often used to partition a two-dimensional space by recursively subdividing it into four quadrants or regions.

How is quadtree stored?

The beauty called a quadtree Trees generally have internal nodes (nodes that have at least one child) and leaf nodes which have no children. These nodes holds data that are ordered in a hierarchical order. A quadtree is a tree data structure in which each node has zero or four children.

How many nodes are in a quadtree?

Thm. A quadtree of depth d storing n points has O((d+1)n) nodes. Proof: Every internal node represents a square with at least 2 points in it.

What is a compressed quadtree?

At the time of storing every node corresponding to a subdivided cell, we may end up storing a lot of empty nodes. Cutting down on the size of such sparse trees is possible by only storing subtrees whose leaves have interesting data (i.e. "important subtrees").


1 Answers

You could pad the image until it is an equal and power of two size. While it may add some extra memory requirements, the increase shouldn't be that large.

The 2x1 example would be padded to a standard 2x2 and store the real size or use a special value for padded nodes so you can restore the original size.

like image 74
MatrixPeckham Avatar answered Sep 25 '22 01:09

MatrixPeckham