【发布时间】:2020-01-14 22:17:11
【问题描述】:
以下是分割掩码的图像(显示为黄色)。覆盖在此蒙版上的是同一分割蒙版的像素/坐标(显示为蓝色)。
我的问题是:为什么这些像素/坐标在对角线上被反转、透明和分割?为什么不将它们绘制为完整的“填充”,例如遮罩本身?
我的目标是让这些坐标以“正常”(x,y) 线性顺序出现。代码:
from matplotlib import patches
import numpy as np
# create mask
mask = np.zeros((350, 525), dtype=np.uint8)
# populate region of mask
mask[2:222,42:521] = 1
# get coordinates of populated region
y, x = np.where(mask == 1)
pts = np.column_stack([x, y])
# define figure, axes, title
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.set_title('Segmentation mask pixel coordinates')
# show mask
plt.imshow(mask, interpolation='none')
# add mask points
poly = patches.Polygon(pts)
ax.add_patch(poly)
plt.show()
【问题讨论】:
标签: python-3.x numpy opencv matplotlib image-segmentation