The entire border of the picture is painted, making the solution almost completely automated. If the outermost columns and ros were cropped out, perhaps the solution might have been more challenging.