上海Python

numpy图片处理

2019-06-21  本文已影响0人  徐_c90e
莲.jpg
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
上一篇 下一篇

猜你喜欢

热点阅读