General method for image reading

1. PIL: reading the image format

1)

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

Output:

<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)

Output:

<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. The common image processing method

 

 

 

Guess you like

Origin www.cnblogs.com/shuangcao/p/12058610.html