Reslice of ImageData and glyph3D arrows

The probe filter works the other way around: the “Source” has the attributes you want (the vectors), and the “Input” has the point grid to use for the output. But I’ve been thinking, and the probe filter is probably not the best solution for you, since you already have something that almost works with vtkImageReslice (and ImageReslice is also much faster than Probe, since it is designed specifically for image data).

I remembered some old code that I wrote that does something similar to what you want. In my case, I had tensor values for every voxel in my image volume and I displayed them with vtkImageReslice and vtkTensorGlyph. The code is here and the resulting image looked like this:

The trick was to create a temporary image where the “Tensors” were moved to the “Scalars” so that vtkImageReslice would reslice them. Something like the following:

# make a new data set where tensors are scalars
vtkSmartPointer<vtkImageData> tensorsAsScalars =
  vtkSmartPointer<vtkImageData>::New();
tensorsAsScalars->CopyStructure(tensorData);
tensorsAsScalars->GetPointData()->SetScalars(
  tensorData->GetPointData()->GetTensors());

# reslice works because the data is stored as Scalars
tensorReslice->SetInputData(tensorsAsScalars);

# put the scalar data back into "Tensors" for use by vtkTensorGlyph
vtkSmartPointer<vtkImageData> tensorsData2 =
  vtkSmartPointer<vtkImageData>::New();
tensorsData2->CopyStructure(tensorReslice->GetOutput());
tensorsData2->GetPointData()->SetTensors(
  tensorReslice->GetOutput()->GetPointData()->GetScalars());

In my case, I wasn’t applying any rotation when I was reslicing, so I didn’t have to rotate the tensors after resampling them.