<filename>python_pillow_numpy/211.convert.posterize.py

from PIL import Image
import numpy as np


#-- read pixels to ndarray
im0  = np.array(Image.open('../images/img001.png').convert('RGB'))


#-- pixel operation
q = 64
im4 = (im0 // q) * q


#-- save to png
Image.fromarray(im4).save('z211.png')


<filename>python_pillow_numpy/211.convert.posterize.py

from PIL import Image
import numpy as np


#-- read pixels to ndarray
im0  = np.array(Image.open('../images/img001.png').convert('RGB'))


#-- pixel operation
q = 64
im4 = (im0 // q) * q


#-- save to png
Image.fromarray(im4).save('z211.png')


#-- read pixels to ndarray #-- pixel operation #-- save to png