Search the closest point

Hi;
I have found many spatial locators like : vtkPointLocator, vtkKdTree, and vtkOctreePointLocator, but I am confused about the most efficent one.

I have a polydata from which I construct a vtkImageData using some filters like (vtkPolydataToImageData, vtkExtruderFilter and vtkImageStencil).I want for each point in the polydata search the closest point in the vtkImageData and extract the scalar value.

My question is : what is the the best spatial Locator which I can use in this case.

thank you very much in advance

There is no “best” one (otherwise only that one would be kept in VTK and the others would be removed). Each has its own advantages and disadvantages. Also note that there are many other locators, including cell locators (which provide nearest position on the surface, not the nearest mesh point).

vtkImageData is solid structured grid block, so you don’t need to use locator to get voxel position (locators are only for meshes).

You can get image scalar value at all points of a model using vtkProbeFilter. It is available in Slicer with a convenient GUI in “Probe volume with model” module.

Hi Mr;

I have constructed vtkImageData from a set Of planar Contours (after doing some operations inspired from SlicerRT : fixHoles, sort Contours…) the imageData is well reconstruted in some cases.

Now I want retrieve for each polydata point of contour, scalar value from vtkImagedata.

I threw a glance on “ProbeVolume with Model” .cxx code. But, to be able to Apply vtkProbFilter I must do some conversions between spaces (ijk To RAs). How can I get IJKTo Ras Matrix from the reconstructed imagedata in my case?

You can do the same as it is done in “Probe volume with model” module.

1 Like