python image new grayscale code example
Example 1: pillow image from array
PIL.Image.fromarray(your_array)
Example 2: convert rgb image to binary in pillow
from PIL import Image
col = Image.open("cat-tied-icon.png")
gray = col.convert('1')
bw.save("result_bw.png")