[vtkusers] How to get voxel value from vtkImageData using C++?

Yi-Yu Chou chouyiyu at hotmail.com
Mon Jan 19 15:27:14 EST 2004


Hi,

I built a vtk class, and I passed a vtkImageData from python to it. In this 
function I want to read the intensity of one voxel, and the function is 
like :

void vtkLocalExample::SetOriImg(vtkImageData *img)
{
  vtkPointData* pData = (vtkPointData*) img->GetPointData();
  vtkDataArray* imgArray = (vtkDataArray*) pData->GetScalars();
  float vox_val = imgArray->GetComponent(2000000,0);   
  printf("voxel value = %f \n", vox_val);
}

However, I got nothing from the output :
voxel value = nan
ps. the image size is 256x256x124
What's wrong with my code ?
Any suggestion would be appreciated !!!

YY

_________________________________________________________________
免費試聽 MSN 英語學習:和真人老師線上學英文 http://www.msn.com.tw/english/ 




More information about the vtkusers mailing list