Comments (10)
Hi @qiang-zhang-neu
thanks for your feedback.
It's right to say that your example returns an empty image/volume (here is the minimal code to reproduce, needing itk itk-thickness3d numpy imageio
):
import itk
import numpy as np
import imageio
# create the original test array
array = np.zeros((256,256,256),dtype=np.int16)
array[50:100, :, :] = 1
# cast to itk image
image = itk.GetImageViewFromArray(array)
# extract the skeleton
skeleton = itk.BinaryThinningImageFilter3D(image)
# cast back the skeleton from itk to numpy
output = itk.GetArrayViewFromImage(skeleton)
# simple way to see if output is empty:
print("original object size : {} vx".format(np.sum(array)))
print("skeleton size : {} vx".format(np.sum(output)))
# export as tiff objects fot visualization
imageio.volwrite("in.tif", array)
imageio.volwrite("out.tif", output)
It is right that with several "perfect" geometrical objects this algorithm has a strange behavior (see comments in the original post).
I personnaly observed these with spheres … but did not impact the computations with actual non-geomatricaly-perfect objects …
I Don't have any suggestions or answer for you … try testing using your real data and see how it works …
Alternatively you can try using the test data provided along with the module to see how it works with branch-like objects
from itkthickness3d.
@T4mmi I managed to overcome Swig problems, see #33 . Now I'm hit by this problem.
For a real medical boolean 3D image, the result was actually sort of the expected 3D surface (for both methods in the module) except not really: almost all points in the skeleton are not there.
That is, the skeleton has withered into thousands of tiny disconnected islands, most of size 1. The erosion clearly is too aggressive.
Moreover, for the little tiff test data you mentioned above (part of the package), I get an all black result image.
So, yes, I see empty or almost empty outputs, too.
That's a shame, because the existing ITK thinning algorithm seems to be 2D based and it produces very bad artefacts when applied to 3D, so it's not really useable.
Do you know of any alternatives in other morphological software? The algorithmic problem of skeletonization appears to be solved in a number of ways, but the frustrating thing is that I can't find an implementation that works...
from itkthickness3d.
@fusentasticus You can try sgext, as commented in this ITK discourse post.
It was born in my PhD thesis, but recently has matured quite a lot, including 100% python bindings of al C++ functionality.
The documentation is good, but the "intros" and a documentation with a bit more narrative is lacking. However for a 3D thinning, the README might suffice. In python, you won't need more than:
pip install sgext
import sgext
sgext.read_binary_image?
sgext.create_distance_map? # To ensure you get a centered skeleton.
sgext.thin?
Hope it helps, the algorithm is more reliable than the 3D thinning used in this module (it's just more recent research from digital topology groups), however it might use more memory and CPU.
If you have any doubt/question, open an issue there.
Hope it helps.
from itkthickness3d.
@phcerdan Much thanks! I'll try it out. Also, the paper https://hal.archives-ouvertes.fr/hal-01217974/document that you cite on your site is a nice reference on trade-offs in how you even define the skeleton. It also has plenty of comparisons to at least some of the other work. And I gather that's the starting point for your own work.
I don't know how it relates to Hanno Homann's work Implementation of a 3D thinning algorithm. That's what this ITKThickness3D module is based on apparently.
from itkthickness3d.
skeleton = itk.BinaryThinningImageFilter3D.New(itkImage)
skeletonImg = skeleton.GetOutput()
Before calling .GetOutput()
, call .Update()
on the produce the output.
Or, use the functional interface, i.e.
skeletonImg = itk.binary_thinning_image_filter3_d(itkImage)
from itkthickness3d.
Before calling
.GetOutput()
, call.Update()
on the produce the output.
Yes, it works now and it produces a wire skeleton. Thanks @thewtex.
However, I still think the claim in the README:
The skeletonization insure a minimal set of measurements to fully describe the object.
is incorrect (and not only for grammar!). For a thin sheet, a filamentous tree is calculated, but he union of the corresponding calculated spheres is not the object. That's because voxels are deleted as long as they don't destroy connectivity with no regard to geometry.
(@phcerdan's sgext algorithm is able to deal with surfaces that are to be reflected in the skeleton)
from itkthickness3d.
@phcerdan Hi! thank you for your contribution. I would like to calculate the medial axis from the skeleton, so i need an extra information related to the distance information. Do you have any suggested function in sgext compatible with python?
from itkthickness3d.
@charlotte10170 you just need to pass a distance_map image (with the distance information) to the thin algorithm and the result will be the medial axis. Read sgext.thin?
.
Please note that your input image needs to be isotropic (the spacing must be equal in all the axes) for the result to be centered in physical space.
Open an issue in https://github.com/phcerdan/sgext if you have further questions.
from itkthickness3d.
@phcerdan Thanks a lot for your help, i solved my problem
from itkthickness3d.
is incorrect (and not only for grammar!). For a thin sheet, a filamentous tree is calculated, but he union of the corresponding calculated spheres is not the object. That's because voxels are deleted as long as they don't destroy connectivity with no regard to geometry.
@fusentasticus makes sense. Could you please create a PR to update the grammar, description, and add a pointer to sgext in the README?
As it looks like the original issue is now resolved, closing this. If there are additional follow ups or other issues, let's please create new separate issues to track them.
from itkthickness3d.
Related Issues (17)
- Remove Thickness3D_LIBRARIES HOT 1
- Question regarding spurious branches in computed centerline HOT 2
- Segmentation fault when calling MedialThicknessImageFilter3D on Linux HOT 3
- Data/medial_thickness.tif is missing HOT 4
- itkMorphologicalDistanceTransformImageFilter instead of itkSignedMaurerDistanceMapImageFilter HOT 2
- Input 3D image format support HOT 5
- Restrict wrapping to 3D HOT 4
- Problem with ITK 5.1.0 HOT 2
- Running with AttributeError HOT 7
- No module named 'itkHelpers' HOT 5
- Build with older ITK version HOT 1
- Consider publishing ARM bdist wheels for MacOS HOT 5
- Medial thickness values HOT 2
- Import error with new itk version 5.3.0 HOT 2
- Is this a seperate module? Or is this a sub-module of ITK? HOT 2
- Not found MedicalThicknessImageFilter3D HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from itkthickness3d.