【发布时间】:2021-03-07 02:44:32
【问题描述】:
上面是一张经过ndi.label()并用matplotlib显示的图像,每个彩色区域代表一个不同的特征。绘制在图像顶部的是红点,每个红点代表一对坐标。所有坐标都被存储并且 ndi.label 返回特征的数量。 skimage、scipy 或 ndimage 是否具有测试给定坐标集是否位于标记特征内的函数?
最初我打算使用每个特征的绑定框(左、右、上、下),但由于这些区域并非都是四边形的,因此这行不通。
生成图像的代码:
image = io.import("image path")
labelledImage, featureNumber = ndi.label(image)
plt.imshow(labelledImage)
for i in range(len(list))
y, x = list[i]
plt.scatter(y,x, c='r', s=40)
【问题讨论】:
-
坐标是如何存储的?标记的图像是一个 numpy 数组吗?你能展示生成它的代码吗?
-
@user13044086 图片是一个numpy数组,这是通过skimage默认的。坐标存储在一个列表位置,这样:对于 i 对坐标:x, y = list[i]
-
你能检查给定坐标的 labelledImage 的所有元素是否相同吗?像这样:
[labelledImage[y, x] for x, y in list]然后检查 ell 元素是否相同
标签: python matplotlib scipy scikit-image ndimage