图像读取的一般方法

1. PIL:读取的是图像格式

1)

    image = Image.open(r'./Input/Images/33039_LR.png')
    print(image)

输出结果:

<PIL.PngImagePlugin.PngImageFile image mode=RGB size=80x120 at 0xD5E8400>

2)

1     image = Image.open(r'./Input/Images/33039_LR.png').convert('RGB')  PIL.Image.Image对象
2     print(image)
3     w,h = image.size
4     print(w,h)

输出结果:

<PIL.Image.Image image mode=RGB size=80x120 at 0xA079B00>
80 120

3)

1     import numpy as np
2     image = Image.open(r'./Input/Images/33039_LR.png').convert('RGB')
3     img = np.array(image)
4     print(img)# 0-255

2.常用的图像处理方法

 

 

猜你喜欢

转载自www.cnblogs.com/shuangcao/p/12058610.html