【发布时间】:2019-05-13 09:35:42
【问题描述】:
我有以下 Python 代码,它在检测到的片段周围添加了一个边界框
%matplotlib qt
fig, ax = plt.subplots(figsize=(10, 6))
ax.imshow(image_label_overlay)
for region in regions:
# take regions with large enough areas
if region.area >= 100:
# draw rectangle around segmented coins
minr, minc, maxr, maxc = region.bbox
rect = mpatches.Rectangle((minc, minr), maxc - minc, maxr - minr,
fill=False, edgecolor='red', linewidth=2)
ax.add_patch(rect)
ax.set_axis_off()
plt.tight_layout()
plt.show()
我不想绘制边界框,而是想对段进行编号。即我想在每个段的中心添加一个数字。我该怎么做?
【问题讨论】:
-
pyplot.text允许您插入文本。你图片中的坐标就是文字的位置:matplotlib.org/api/_as_gen/matplotlib.pyplot.text.html -
好的,这就是工作。谢谢!
标签: python image image-processing label image-segmentation