Extended algorithm to construct a quadtree from freeman chain code in four directions