I’ve drawn a closed curve on DICOM image. How do you calculate centroid of closed curve?
Can you approximate ellipse from closed curve and calculate longest and short axis of this ellipse?
I would like to implement this steps in a script, but haven’t found anything similar in script repository (there is and example of segment statistics, but I draw my closed curve on raw DICOM not on segmented images).

You can use something like slicer.util.arrayFromMarkupsCurvePoints(slicer.util.getNode("CC")) where “CC” is the default name of the closed curve. With that array you can do whatever fitting and calculations you need. Along with the examples in the script repository you should have what you need.

To fit an ellipse to the curve, you can slightly modify the sphere fitting example in the script repository. Or, you can project all your curve points to a best-fit plane and then do a 2D ellipse fitting.