如何使用python测量骨架长度的想法 [英] Ideas how to measure the length of a skeleton using python

查看:52
本文介绍了如何使用python测量骨架长度的想法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在image()上应用

我想使用python测量最长的分支或骨骼的脊柱.ImageJ有几种工具可以完成这项工作,一种是

After applying

I want to measure the longest branch, or spine of the skeleton using python. ImageJ has several tools that do this job one is Measure_Skeleton_length, another is AnalyzeSkeleton. Any tools or suggestions in python?

解决方案

This comes as a very late reply to the original question, but just in case someone who still is in need might end up reading this post. There is an awesome python package for analyzing skeletons called FilFinder (pip install fil_finder) which solves this problem elegantly. Below is a code adopted from their 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()

which outputs

这篇关于如何使用python测量骨架长度的想法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆