An Algorithm for Converting Rasters to Quadtrees

An algorithm is presented for constructing a quadtree for a binary image given its row-by-row description. The algorithm processes the image one row at a time and merges identically colored sons as soon as possible, so that a minimal size quadtree exists after processing each pixel. This method is spacewise superior to one which reads in an entire array and then attempts to build the quadtree.