Reduce number of layers in images