python图像——简易读取及处理

0.用到的模块

# 读图、保存
from PIL import Image
# 图像处理
import numpy as np

1.用到的函数

# 1.图像读取
img = Image.open('C:/Users/Saved Pictures/1.jpg')

# 2.图像转换
img.convert('L')

# 3.图像转二维数组
img_array = np.array(img)

# 4.数组转图像
img = Image.fromarray(img_array)

# 5.图像显示
img.show()

# 6.图像保存
img.save(fp = 'C:/Users/Saved Pictures/2.jpg')

你可能感兴趣的:(Image,python)