擅长:python、mysql、java
<p>你提到的方法应该可以很好的工作,你只需要做一个形态学操作之前,减少线的宽度到一个像素。您可以使用scikit图像来实现:</p>
<pre><code>from skimage.morphology import medial_axis
import cv2
# read the lines image
img = cv2.imread('/tmp/tPVCc.png', 0)
# get the skeleton
skel = medial_axis(img)
# skel is a boolean matrix, multiply by 255 to get a black and white image
cv2.imwrite('/tmp/res.png', skel*255)
</code></pre>
<p><a href="https://i.stack.imgur.com/TORGS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TORGS.png" alt="enter image description here"/></a></p>
<p>见<a href="https://scikit-image.org/docs/dev/auto_examples/edges/plot_skeleton.html" rel="nofollow noreferrer">this page</a>关于skimage中的骨骼化方法。在</p>