使用VTK的阈值图像数据(vtkImageThreshold)

时间:2013-10-23 19:27:24

标签: c++ vtk

我有一个3D矢量字段,我存储在vtkImageData对象中。 vtkImageData对象包含两个数组:

  1. 3组件vtkDoubleArray(向量x,y和z组件)
  2. 包含单独数量的1个组件vtkDoubleArray
  3. 我想提取两个数组的相应元素,其中1分量数组的值位于特定范围内。这是我尝试过的:

    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();
    

    我也尝试过使用vtkThresholdPoints但无济于事。任何建议都会非常感激。

1 个答案:

答案 0 :(得分:0)

看起来我可以使用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();

我没有意识到这种方法适用但似乎是这样。这确实会将我的数据类型从vtkImageData更改为vtkPolyData,而我很少知道vtkThresholdPoints::SetInputArrayToProcess()的参数意味着什么。但是,它似乎完成了这项工作。我很乐意听到任何其他建议!