Generates the closest image to a 16777216-pixel image with the all RGB colors and the same dimensions