refactor overlay function out of process_image