from PIL import Image
import numpy as np
im = np.array(Image.open('E:/python编程/柠檬.jpg'))
print(im.shape,im.dtype)
im
b = [255, 255, 255] - im #数组运算
new_im = Image.fromarray(b.astype('uint8'))
new_im.save('E:/python编程/柠檬NEW.jpg') #保存为新图像
b

from PIL import Image
import numpy as np
im = np.array(Image.open('E:/python编程/柠檬.jpg'))
print(im.shape,im.dtype)
im
b = [255, 255, 255] - im #数组运算
new_im = Image.fromarray(b.astype('uint8'))
new_im.save('E:/python编程/柠檬NEW.jpg') #保存为新图像
b