numpy图片处理

作者: 徐_c90e | 来源:发表于2019-06-21 22:39 被阅读0次
莲.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

相关文章

网友评论

    本文标题:numpy图片处理

    本文链接:https://www.haomeiwen.com/subject/wujpqctx.html