[vtkusers] GetCenter of vtkImageData - a possible bug?

chasank chasank at gmail.com
Wed Mar 19 07:06:52 EDT 2014


Hi,

I have a nifti image that has these features below:

     Dimensions : {301, 370, 316}
     Origin : {75, 107, -69.5}
     Spacing : {0.5, 0.5, 0.5}

I want to get center world point of the image. When I use GetCenter method
of vtkImageData for this purpose, I get {150, 199.25, 9.25}. However, I
suspected that it seems a bit wrong. And then I tried to calculate the
center point on my own like below:

     double origin[3], spacing[3], center[3];
     int dimensions[3];

     imageData->GetOrigin(origin);
     imageData->GetSpacing(spacing);
     imageData->GetDimensions(dimensions);

     for(int i = 0; i < 3; i++)
     {
         center[i] = origin[i] + ((dimensions[i] / 2) * spacing[i]);
     }

and center world point becomes {150, 199.5, 9.5}. So which result is true?
My calculation or GetCenter method?

Best regards.
Chasan



--
View this message in context: http://vtk.1045678.n5.nabble.com/GetCenter-of-vtkImageData-a-possible-bug-tp5726392.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list