import numpy as np
from PIL import Image
pic=Image.open('莲.jpg')
print(type(pic))
im=np.array(pic)
print(im.shape,im.dtype,im.ndim,im.itemsize)
print(im.flags)
a=[255,255,255] - im
newim=Image.fromarray(a.astype('uint8'))
newim.save('底片莲.jpg')
b = [0.5,0.5,0.5] * im +[256*0.25 -1 ,256*0.25 -1 ,256*0.25 -1]
newim=Image.fromarray(b.astype('uint8'))
newim.save('朦胧莲.jpg')
c = [0.25,0.25,0.25] * im
newim=Image.fromarray(c.astype('uint8'))
newim.save('晚上莲.jpg')
底片莲.jpg
朦胧莲.jpg
晚上莲.jpg
网友评论