[vtkusers] Get the right voxel from the GetScalarPointer method

Matei MANCAS matei.mancas at tcts.fpms.ac.be
Fri May 16 09:34:32 EDT 2003


Hi !

I found the problem :

The magic formula is voxel[x+y*dim(x)+z*dim(x)*dim(y)] but the problem was the scalar type which was not float but unsigned short!!!

Conclusion : take really care about your scalar type :-)

Matei 


  ----- Original Message ----- 
  From: Matei MANCAS 
  To: vtkusers at public.kitware.com 
  Sent: Thursday, May 15, 2003 6:02 PM
  Subject: [vtkusers] Get the right voxel from the GetScalarPointer method


  Hi everybody!!!

  I'm trying to directly access to image voxels. 

  I first tried this :
  float* voxel=(float*)(mon_grad->GetOutput()->GetScalarPointer(x,y,z));
  voxel[0] contains the value of voxel placed in x, y and z so it works well...

      BUT 

  I need to use the more complicated way :
  float* voxel=(float*)(mon_grad->GetOutput()->GetScalarPointer());

  In this case voxel is a pointer on the first element of a 1 dimensional Tab....
  Does anyone knows how this structure is really made???

  I tried to get the x,y,z voxel by doing :

  voxel[x+y*dim(x)+z*dim(x)*dim(y)] or
  voxel[z+y*dim(z)+x*dim(x)*dim(z)] or others....

  And it never worked or is never the same voxel then when I use the first method!

  So please help me : what is the magic formula to get the right voxel from a 
  float* voxel=(float*)(mon_grad->GetOutput()->GetScalarPointer());


  Thanks by advance!

   
  Matei 




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030516/7bcbd6ae/attachment.htm>


More information about the vtkusers mailing list