修剪python图像骨架并找到最长路径

修剪python图像骨架并找到最长路径,python,opencv,mathematical-morphology,Python,Opencv,Mathematical Morphology,我有以下图片,我想修剪树枝: 输入: 当我使用中描述的方法时 我得到这个结果: 最长路径: 然而,我想要的结果是:(人工制造) 期望输出: 使用的代码: from fil_finder import FilFinder2D import astropy.units as u fil = FilFinder2D(skeleton2, distance=250 * u.pc, mask=skeleton2) fil.preprocess_image(flatten_percent=85) f

我有以下图片,我想修剪树枝:

输入:

当我使用中描述的方法时 我得到这个结果:

最长路径:

然而,我想要的结果是:(人工制造)

期望输出:

使用的代码:

from fil_finder import FilFinder2D
import astropy.units as u

fil = FilFinder2D(skeleton2, distance=250 * u.pc, mask=skeleton2)
fil.preprocess_image(flatten_percent=85)
fil.create_mask(border_masking=True, verbose=False,
use_existing_mask=True)
fil.medskel(verbose=False)
fil.analyze_skeletons(branch_thresh=40* u.pix, skel_thresh=10 * u.pix, prune_criteria='length')

# Show the longest path
plt.imshow(fil.skeleton, cmap='gray')
plt.contour(fil.skeleton_longpath, colors='r')
plt.axis('off')
plt.show()
我想也许可以通过找到分支点,然后删除最短路径来获得所需的输出。有人知道如何做到这一点吗