pillow ---- PIL, pure python image rendering library 纯Python图像处理库

方法

Access a pixel

im.getpixel((row, col))

im.load()

1
2
pixel_data = im.load()
pixel_data = [255,255,255]

im.putpixel((row, col), color)

numpy.array <–> PIL image

PIL image –> numpy.array

1
2
3
4
5
from PIL import Image
import numpy as np
im = Image.open('hopper.jpg')
arr = np.asarray(im)
arr01 = np.array(im)

np.array –> PIL Image

1
im = Image.fromarray(a)