[vtkusers] GetCenter of vtkImageData - a possible bug?
John Drescher
drescherjm at gmail.com
Wed Mar 19 07:14:51 EDT 2014
> 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?
>
Should dimensions be a double in your calculation instead of int?
John
More information about the vtkusers
mailing list