Computing distance from point to first non-zero voxel in an image

Given an voxel based image, a point in physical space and a direction vector (i.e., unit vector): can I somehow compute the distance from that point to the first non-zero voxel in the image in the given direction?
Ideally available in the Python API :sweat_smile: But C++ would also be fine.

I already found the LineIterator and it would be possible to calculate a starting and end point in voxel coordinates, then iterate the voxels, find the first non-zero one and calculate the distance. But maybe there is something I missed and such a function is already implemented, especially one that takes physical coordinates and vectors?

Hello @reox,

A related task, summation of intensities along a ray, is done by the SiddonJacobsRayCastInterpolateImageFunction, possibly useful for this case too.

1 Like

Thanks for the hint, that looks indeed useful!