ImageMomentsCalculator how to in python

I want to use the imageMomentsCalculator to get the “center of mass” of an image how could one do this with the python interface?

it appears its only indirectly available as part registration intialization?

Hi @kayarre,

Center of gravity can be calculated with:

moments = itk.ImageMomentsCalculator.New(image)
moments.Compute()
center_of_gravity = moments.GetCenterOfGravity()

Hope this helps,
Matt

2 Likes