显示图像
from PIL import Image
im = Image.open("hopper.ppm")
from _future_ import print_function
print(im.format, im.size, im.mode)
im.show()
显示缩略图
示例代码如下:
im.thumbnail(size)
im.save(outfile, "JPEG")
写图像
示例代码如下:
im.save(outfile, "JPEG")
# 或者
im.save(r'C:\Users\Administrator\Desktop\rabbit_copy.jpg')
Image与ndarray之间的转换
Image转化为ndarray
ndarray=np.array(Image)
# 或者
ndarray = np.asarray(Image)
ndarray转化为Image
im = Image.fromarray(a)
高宽或size的顺序
Image读图片的大小是图片的(width, height),即img.size的返回值
Image没有shape属性
box或rect的顺序
box is a 4-tuple, where coordinates are (left, upper, right, lower),即(x1,y1,x2,y2)
pillow的坐标系统
横为x轴,纵为y轴