vtkProbeFilter with oriented image

Hi all

Maybe a question for @lassoan

I have seen that vtkDiscreteMarchingCube has been updated for oriented image. And indeed the IndexToPhysicalMatrix is used through the TransformPoints method at the end of the method.

When I try to use the vtkProbeFilter using the output of discrete marching cube as input, and distance map computed before on the same image as source, the probe contains 0. The only solution is to set direction matrix to identity to all the images before the marching cube.

My images are NIFTI. I corrected the direction matrix using the QForm matrix:

Pipelines before the orientation (I already checked that these pipelines produce excepted results)
→ segment the images
→ compute distance map from segmentation
→ store all image results as nifti files

mat= vtk.vtkMatrix4x4()
mat.DeepCopy(vtk_nifti_reader.GetQFormMatrix())
direction = []
origin = []
for k in range(3):
    factor = -1 if k<2 else 1
    for j in range(3):
        direction.append(factor*mat.GetElement(k,j))

for i in range(3):
    factor = -1 if i<2 else 1
    origin.append(factor*mat.GetElement(i,3))

my_vtk_image_segmented.SetOrigin(origin)
my_vtk_image_segmented.SetDirectionMatrix(direction) 

my_vtk_image_distance_map.SetOrigin(origin)
my_vtk_image_distance_map.SetDirectionMatrix(direction) 

Probe Pipeline

probe_filter = vtk.vtkProbeFilter()
probe_filter.SetCategoricalData(False)
probe_filter.SetPassCellArrays(True)
probe_filter.SetPassFieldArrays(True)
probe_filter.SetPassPointArrays(True)
probe_filter.SetSourceData(my_vtk_image_distance_map)
probe_filter.SetInputConnection(my_vtk_image_segmented)
probe_filter.Update()
probe_filter.GetOutput()

When displaying it using colormap, I have not distance displayed. When I change reset the orientation to Identity (not set the vtkDirectionMatrix for the images) I have the correct distance displayed.

Wondering if probe filter take into account the Direction matrix? Or if it is the marching cubes ? or a missing matrice inversion?
thanks in advance

I don’t think vtkProbeFilter is appropriate for this. If you want to resample an image in the coordinate system of another image then you can use vtkImageReslice.

If you want to probe a surface with an image (set point scalars based on image data) then vtkImageProbeFilter can be used. It relies on TransformPhysicalPointToContinuousIndex, so it should work well with an arbitrarily oriented image.

1 Like

@lassoan
thanks. I was thinking using the vtkImageProbeFilter. But not it is the probe indeed…