from PIL import Image
import numpy as np
im = np.array(Image.open('F:/PY数据分析练习/4.jpg'))
print(im.shape,im.dtype)
b = [255, 255, 255] - im/2 #数组运算
new_im = Image.fromarray(b.astype('uint8'))
new_im.save('F:/PY数据分析练习/5.jpg') #保存为新图像
from PIL import Image
import numpy as np
im = np.array(Image.open('F:/PY数据分析练习/4.jpg'))
print(im.shape,im.dtype)
b = [255, 255, 255] - im/2 #数组运算
new_im = Image.fromarray(b.astype('uint8'))
new_im.save('F:/PY数据分析练习/5.jpg') #保存为新图像