ITK octree

Hi, I am trying to use Octrees on ITK, I saw that ITK have an Octree object. However, I can not find the methods of Octree to get the closest points.

My problem is that I have a region of interest composed of several voxels with x,y,z coordinates in a .nrrd image. I want to put several voxels of this image into an octree structure to query the closest distance to my region of interest. I thought to use Octrees similar to VTK object, but I couldn’t find methods to encode my idea. I saw KD-tress but I am not sure if that structure is the same concept that octree.

Thanks in advance.

Hi @rolof,

Yes, the KD-tree can likely provide the desired functionality. Here is an example:

https://itk.org/ITKExamples/src/Numerics/Statistics/SpatialSearch/Documentation.html

More information can be found in Section 5.1.7 of the ITK Software Guide.

1 Like

Ok thank you @matt.mccormick, but in that case, do you know what is the purpose of Octree object in Itk?

And another question, do you know where could I find alternatives to distance search in ITK library? I thought in Octree or Brute force, but I do not know if ITK has a specific section or set of objects to solve this problem.

Thank you again!

1 Like

The Octree class was likely brought in from VTK, but it has not matured.

Yes, you are on the right track with Kd-tree for efficient distance searches. There are examples of application in @ntustison 's ITK-v4 point-set metrics.

Have you considered distance transform? Maurer filter is the fastest one in ITK proper.

1 Like

Thank you @dzenanz, @matt.mccormick, I am going to take a look to both KD-tree and Maurer filter, I will leave this post opened because probably there are some filters that was not mentioned and I want to test all of them.

Thank you again!

I tested the Maurer filter, I saw that it is only suitable for a binary image, do you know if there is another filter to multi labeled image. I mean imagine the case that you have three types of voxels in an image, 0: Background, 1:object_1, 2:object_2, and you want to compute the euclidean distance for all the points of object_1 to object_2 ignoring the computations of the background. Currently, with the Maurer filter, I do not know how to achieve that.

Thanks in advance!

Binarize your image using threshold filter keeping only object 2. Run Maurer on that. It will compute distances to object 2 for all the pixels of the image, including the ones which belong to object 1. You could then mask the distance image with object 1 label.