合并或删除边缘地图边界上的重复线

问题描述 投票:0回答:0

我正在尝试在图像的所有边缘上精确地绘制一条线。我能够画出线条,但有些线条是重复的,我坚持了好几天,任何帮助将不胜感激。我尝试使用 sklearn 的 KMeans 算法,但仍然不知道它是否是解决问题的正确选择。在边缘地图上生成线条的示例代码是

hspace, angles, distances = hough_line(img) and  accum, angles2, distances2 = hough_line_peaks(hspace, angles, distances, threshold = 3, num_peaks = 13) 

def line(x, rho, theta):
   return (rho - x \* np.cos(theta)) / np.sin(theta)  

plt.imshow(img, "gra")
x = np.linspace(0, 1045000, 50000)
for i in range(13):
plt.plot(x, line(x, distances2\[i\], angles2\[i\]), label = 'line :' + str(i))
plt.xlim((0,img_sliced.shape\[1\]))
plt.ylim((img_sliced.shape\[0\], 0)) 

我使用精明的边缘检测计算了图像的边缘图,边缘图看起来像这样edge map然后我在边缘图上应用了 Hough_line 变换来检测线条,然后应用了 Hough_line_peaks。生成的图像看起来像 lines detected 。正如您从图像中看到的那样,有重复的行,这里的问题是我可以合并它们,或者如果可以的话,甚至删除一个留下另一个。任何想法将不胜感激。

image image-processing k-means hough-transform straight-line-detection
© www.soinside.com 2019 - 2024. All rights reserved.