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

标签 python opencv image-processing contour line-intersection

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

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/

相关文章:

python - 从python中的列表中删除空字符串

c++ - 将 python 与 c++ 接口(interface)

python - 电影全屏

python - 3D Matplotlib 中的动态点操作

android - ConvexHull Android ndk 和 Opencv 中的参数无效

python - 计算图像中白色的总像素数

image-processing - OpenCV - 查找倾斜的矩形

c++ - 编译和使用 OpenCV

python - 从 BGR 到灰度的 OpenCV 颜色转换错误

algorithm - 分层图像的快速子矩形