python - 图像分割 - 如何检测这种静脉连接?(地标)
解决方案
这是个有趣的问题。我得到的结果并不完美,但这可能是一个好的开始。我用只查看内核边缘的内核过滤了图像。这个想法是,一个连接点至少有 3 条线穿过内核边缘,而常规线只有 2 条。这意味着当内核超过一个连接点时,结果值会更高,因此阈值会显示它们.
由于线条的性质,存在一些正面价值和一些假负面。很可能会多次找到单个关节,因此您必须考虑到这一点。您可以通过绘制小点并检测这些点来使它们独一无二。
结果:
代码:
import cv2
import numpy as np
# load the image as grayscale
img = cv2.imread('xqXid.png',0)
# make a copy to display result
im_or = img.copy()
# convert image to larger datatyoe
img.astype(np.int32)
# create kernel
kernel = np.ones((7,7))
kernel[2:5,2:5] = 0
print(kernel)
#apply kernel
res = cv2.filter2D(img,3,kernel)
# filter results
loc = np.where(res > 2800)
print(len(loc[0]))
#draw circles on found locations
for x in range(len(loc[0])):
cv2.circle(im_or,(loc[1][x],loc[0][x]),10,(127),5)
#display result
cv2.imshow('Result',im_or)
cv2.waitKey(0)
cv2.destroyAllWindows()
注意:您可以尝试调整内核和阈值。例如,使用上面的代码,我得到了 126 个匹配项。但是当我使用
kernel = np.ones((5,5))
kernel[1:4,1:4] = 0
有阈值
loc = np.where(res > 1550)
我在这些位置获得了 33 场比赛:
推荐阅读
- php - PHP / laravel将项目添加到会话未保存
- postgresql - 当新行本身有重复时,如何在 Postgresql 中插入不重复的行?
- c - 使用 strstr() 后,子字符串也通过 uart 传输
- android - 如何向特定应用版本用户停用或广播消息?
- javascript - 如果任何文本框输入错误,JQuery 禁用提交?
- c# - 使用 default 作为可空值类型参数的默认值不会分配 null
- https - 如何在 GCP 中使用 https 访问 VM 实例
- javascript - 将 iframe onload 事件附加到某个 div 后触发
- php - 如何隐藏laravel中的关系列?
- html - Next.js background-image css 属性无法加载图片