reduce number of layers in the image