Q:

Threshold image data using VTK (vtkImageThreshold)

I have a 3D vector field that I am storing in a vtkImageData object. The vtkImageData object contains two arrays: 

a 3 component vtkDoubleArray (the vector x, y and z components) 
a 1 component vtkDoubleArray containing a separate quantity

I would like to extract the corresponding elements of the two arrays, for which the values of the 1 component array lie within a certain range. Here's what I've tried:
vtkSmartPointer<vtkImageThreshold> threshold =
        vtkSmartPointer<vtkImageThreshold>::New();
threshold->SetInputData(image);
threshold->SetInputArrayToProcess(1, image->GetInformation()); // 1 is the Energy array index
threshold->ThresholdBetween(1e-22, 2e-22);
threshold->Update();

vtkSmartPointer<vtkImageData> thresholdedImage = threshold->GetOutput();

I've also tried using vtkThresholdPoints but to no avail. Any suggestions would be much appreciated.

A:

Looks like I can use this example:
vtkSmartPointer<vtkThresholdPoints> threshold = 
        vtkSmartPointer<vtkThresholdPoints>::New();
threshold->SetInputData(image);
threshold->ThresholdBetween(1e-21, 2e-21);
threshold->SetInputArrayToProcess(0, 0, 0, 
        vtkDataObject::FIELD_ASSOCIATION_POINTS, "Energy");
threshold->Update();

vtkSmartPointer<vtkPolyData> thresholded = threshold->GetOutput();

I didn't realise that this approach was applicable but it would seem so. This does change the type of my data from vtkImageData to vtkPolyData and I have very little idea what the arguments to vtkThresholdPoints::SetInputArrayToProcess() mean. However, it seems to do the job. I'd be happy to hear any alternative suggestions!

