label_centerlines
label_centerlines copied to clipboard
Obtain the centerlines from 3D binary mask
This label_centerlines is realy a very good project. However, I wonder whether it can provide the center lines from a 3D binary mask?
In addition, currently, I use the skimage.measure.skeleton to obtain the skeletion, but the skeletion is really not smooth and there are some wrong branches. Thus, could you please explain how to exclude the wrong branch and smooth the center line?
Thank you very much!
Hi @qiang-zhang-neu,
I'm not sure what you mean by "3D binary mask". I guess a 2D binary mask in this context is a raster dataset, so in order to use it with this tool you can try to vectorize the raster into a feature and then apply the centerlines algorithm. I don't think this would work for a 3D dataset though.
You use the skeleton as an alternative to the Voronoi approach here? We use the networkx package to build a temporary network graph and then calculate the longest path of all possible paths on that graph. (see https://github.com/ungarj/label_centerlines/blob/master/label_centerlines/_src.py#L66)
Then the tool smoothes the linestring by using NumPy and a Gaussian filter on the xy coordinates: https://github.com/ungarj/label_centerlines/blob/master/label_centerlines/_src.py#L146
I guess this approach will work with a skimage skeleton as well as long as you manage to convert the skeleton into a networkx graph.