The quadtree is an important 2D data structure and forms the core of many spatial algorithms, including compression, collision detection, and stitching algorithms. Below you can download general purpose quadtree implementations in Java and Python.

The code accompanies the Quadtrees article in Dev.Mag. The tutorial explains how the implement a quadtree that can be use to store 2D data efficiently, lists what considerations there are in real-world applications, and gives some debugging tips.

Channels Compressed Simultaneously

bar bar_c
The original image (by smcgee). The image after being loaded into a quadtree.

Channels Compressed Separately

bar_c_0 bar_c_1
Red channel compressed. Green channel compressed.
bar_c_2 bar_d
Blue channel compressed. Compressed channels combined.


Java Implementation

quadtree_java_src.zip (25 KB)

Python Implementation

Download from: http://code-spot.co.za/python-image-code/.