Quadtree or recursion with image sampler

This might be of some help to you.