Get center of gravity of a segment

You can also use segmentation node’s GetSegmentCenter or GetSegmentCenterRAS method. It works for both labelmap and closed surface representations. It is used for giving a position inside the segment (used when you right-click the segment and select “Jump slices”) and so it does not use center of gravity. If you need strictly center of gravity then you can have a look at the source code of this method and create a modified version.