from PIL import Image
import numpy as np
#图像的变换
a = np.array(Image.open(img_path)) #打开
b = [255,255,255] - a #运算
new_img = Image.fromarray(b.astype('uint8')) #生产图像类型
#new_img.show()
new_img.save(new_path) #保存
#对于灰度图的运算
255 - a #取反
(100/255)*a + 150 #区间变换
255 * (a/255)**2 #像素平方
#Image的函数
convert("L") #灰度值
convert("1") #二值化,需要先转为灰度值,与point()的算法差别,还需探究
《Numpy笔记》 4 — 图像变换
最新推荐文章于 2024-08-05 17:04:33 发布