Program calculating photomosaic