python matplotlib
程序员文章站
2022-03-09 19:47:26
...
1. 读入图像并画矩形
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from PIL import Image
img = Image.open(img_path).convert("RGB")
plt.imshow(dataset[0][0])
currentAxis=plt.gca()
# (x, y), width, height
rect=patches.Rectangle((20, 60),50, 50,linewidth=1,edgecolor='r',facecolor='none')
currentAxis.add_patch(rect)
plt.show()