InsightSoftwareConsortium / itk_cucim

ITK Python filters accelerated with cuCIM
Apache License 2.0
3 stars 3 forks source link

Implement distance function filters #13

Open thewtex opened 2 years ago

grlee77 commented 2 years ago

This issue corresponds to the filters in this section? https://itk.org/Doxygen/html/group__ITKDistanceMap.html

SciPy's distance_transform_edt should match ITK's SignedMaurerDistanceMapImageFilter (its C source code mentions the same publication). That is one I had started to work on for the GPU as well (2D and 3D only, though) and could be contributed upstream to CuPy as cupyx.scipy.ndimage.distance_transform_edt. We have also had other requests for that function in the past at the cuCIM repo, so I agree that getting that one completed is a high priority.

Of the other distance transforms, do you have particular ones that are of higher relative priority?

dzenanz commented 2 years ago

Maurer is used the most, by a large margin. Some other filters are probably higher priority than the rest of distance transform filters. Matt could pitch in too.

grlee77 commented 2 years ago

There is now an upstream PR for a fast GPU-based 2D and 3D Euclidean distance transform in cuCIM (target for the August 2022 release). We still need to add support for the sampling argument that lets pixel sizes be specified, but this is a good start toward SignedMaurerDistanceMapImageFilter

grlee77 commented 2 years ago

I think the API implemented there has to be called twice to give the signed version of the distance transform

signed_distance = distance_transform_edt(np.logical_not(image)) - distance_transform_edt(image)
thewtex commented 1 year ago

@grlee77 we are looking at applying a more accurate distance transform in MSK applications:

https://github.com/InsightSoftwareConsortium/ITKParabolicMorphology

If there is a cucim accelerated version, that could be a great story to tell.

CC @sbonaretti

grlee77 commented 1 year ago

Thanks @thewtex I will have to look at that parabolic morphology publication. It is not something we currently have implemented.

There are CUDA kernels in NPP for an "anti-aliased distance transform" for gray-scale images. I think this is a corresponding publication: https://www.sciencedirect.com/science/article/abs/pii/S0167865510002953.