Populated stub algorithm for flatten_image.py