# Center of mass calculation

**URL:** <https://discourse.slicer.org/t/center-of-mass-calculation/38243>\
**Category:** Support\
**Tags:** dicom\
**Created:** [September 5, 2024, 5:38pm UTC](https://discourse.slicer.org/t/center-of-mass-calculation/38243 "2024-09-05T17:38:35Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 6, 2024, 10:48am UTC](https://discourse.slicer.org/t/center-of-mass-calculation/38243/3 "2024-09-06T10:48:41Z")

</div>

@francois You can ignore part of a volume that is outside a segment as @cpinter described. You can also get a point inside a segment nearest to its center using [segmentationNode.GetSegmentCenterRAS](https://discourse.slicer.org/t/get-center-of-gravity-of-a-segment/4287/4) (this is useful if you want to jump to a slice where the segment is visible; the center of gravity may be outside the segment). If to7 want to compute the center of gravity yourself then you can do so using numpy (you can use `np.where` to ignore values that are outside the range you are interested in).

Note that 0 HU value corresponds to water (fat, soft tissue, …) so it might not be suitable as a threshold. HU value of air is -1000, you can use that as a thrshold for determining if a voxel is “empty”.

What would you like to use center of gravity for?

---

_[View the full topic](https://discourse.slicer.org/t/center-of-mass-calculation/38243)._
