from PIL import Image
import numpy as np
a = np.array(Image.open("fcity.jpg"))
print(a.shape, a.dtype)
b = [255, 255, 255] - a
im = Image.fromarray(b.astype('uint8'))
im.save("a.jpg")
原图:
变化过的图片
from PIL import Image
import numpy as np
a = np.array(Image.open("fcity.jpg").convert('L')<