gpt4 book ai didi

python - 在 python opencv 中查找骨架化图像的交集

转载 作者:太空宇宙 更新时间:2023-11-03 21:17:24 25 4
gpt4 key购买 nike

我有一个骨架图像(如下所示)。

Skeleton Image

我想得到直线的交点。我尝试了下面的方法,skeleton 是一个 openCV 图像,算法返回一个坐标列表:

def getSkeletonIntersection(skeleton):
image = skeleton.copy();
image = image/255;
intersections = list();
for y in range(1,len(image)-1):
for x in range(1,len(image[y])-1):
if image[y][x] == 1:
neighbourCount = 0;
neighbours = neighbourCoords(x,y);
for n in neighbours:
if (image[n[1]][n[0]] == 1):
neighbourCount += 1;
if(neighbourCount > 2):
print(neighbourCount,x,y);
intersections.append((x,y));
return intersections;

它找到有两个以上相邻像素的白色像素的坐标。我认为这只会返回角球,但它不会 - 它会返回更多的分数。

Skeleton with marked coordinates

这是在图像上标记了检测到的点的输出。这是因为它检测到下面显示的一些不是交叉点的示例。

0 0 0    1 1 0    0 1 1
1 1 1 0 1 0 1 1 0
0 0 1 0 0 1 0 0 0

还有更多例子。我应该看看另一种检测交叉点的方法吗?感谢所有输入和想法,谢谢。

最佳答案

我不确定 OpenCV 功能,但您或许应该尝试使用 Hit and Miss 形态学,它描述了 here .

阅读 Line Junctions 并查看您需要测试的 12 个模板:

enter image description here

关于python - 在 python opencv 中查找骨架化图像的交集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41705405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com