Reputation: 1
I'm trying to draw exactly one line on all the edges of an image. I was able to draw the lines but some of the lines are repeated and I'm stuck on it for days, any help would be appreciated. I tried using the KMeans algorithm from sklearn but still don't even know if it's the correct choice for solving the issue. the sample code that produced the lines on the edge map is
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))
I Computed the edge map of the image using a canny edge detection the edge map looks like this edge mapthen I applied the Hough_line transform on the edge map to detect the lines and then applied the Hough_line_peaks. the resulting image looks like lines detected .as you can see from the image there are duplicated lines the question here is can I merge them or even remove one leaving the other if that is an option. any ideas will be appreciated.
Upvotes: 0
Views: 161