python - 想法如何使用python测量骨架的长度

标签 python image-processing scipy scikit-image

申请后skeletonization在图像上(),enter image description here

我想使用 python 测量骨架的最长分支或脊柱。 ImageJ 有几个工具可以完成这项工作,一个是 Measure_Skeleton_length , 另一个是 AnalyzeSkeleton . python 中的任何工具或建议?

最佳答案

这是对原始问题的一个很晚的答复,但以防万一仍然有需要的人最终可能会阅读这篇文章。有一个名为 FilFinder (pip install fil_finder) 的用于分析骨架的很棒的 python 包,它优雅地解决了这个问题。以下是从他们的 tutorial 中采用的代码

import numpy as np
import cv2
import matplotlib.pyplot as plt
from fil_finder import FilFinder2D
import astropy.units as u

skeleton = ... #in numpy array format

fil = FilFinder2D(skeleton, distance=250 * u.pc, mask=skeleton)
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')

plt.imshow(fil.skeleton, cmap='gray')
plt.contour(fil.skeleton_longpath, colors='r')
plt.axis('off')
plt.show()

输出

enter image description here

关于python - 想法如何使用python测量骨架的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33979742/

相关文章:

python - KS 测试的非标准分布变量?

php - 运行非常长的脚本 - 如何让它们保持运行并在它们失败时重新启动它们?

python - 使用python选择图像的区域

python - 如何从两个插值函数的乘积创建新函数?

python - 如何在 OpenCV 中找到二进制骨架图像的端点?

ios - 整个图像的特定帧中的边缘检测

python - scipy logsumexp() 是否处理下溢挑战?

python - 生成总和为给定数字的二进制列表

python - pandas-resetting cumsum 在一个特定的数字

python - 字符串索引超出范围 - 索引错误