2013-10-23 195 views
0

我有一個3D矢量字段,我存儲在一個vtkImageData對象。所述vtkImageData對象包含兩個數組:使用VTK閾值圖像數據(vtkImageThreshold)

  1. 一個3成分vtkDoubleArray(矢量x,y和z分量)
  2. 含有一個單獨的量

1個部件vtkDoubleArray我想提取兩個陣列的相應元素,其中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,但無濟於事。任何建議將不勝感激。

回答

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()的參數意味着什麼。但是,它似乎在做這項工作。我很樂意聽到其他建議!