Restore image from rectangles method implementation.