Skip to content

eccentricity

cellseg_gsontools.geometry.eccentricity(polygon, **kwargs)

Compute the eccentricity of a polygon.

Note

Eccentricity (sometimes ellipticity) measures how far the object is from an ellipse. It is defined as the ratio of the length of the minor axis to the length of the major axis of an object. The closer the object is to an ellipse, the closer the eccentricity is to 1 - Wirth

Eccentricity: $$ \sqrt{1 - \frac{\text{minor axis}^2}{\text{major axis}^2}} $$

Parameters:

Name Type Description Default
polygon Polygon

Input shapely polygon object.

required

Returns:

Name Type Description
float float

The eccentricity value of a polygon between 0-1.

Source code in cellseg_gsontools/geometry/shape_metrics.py
def eccentricity(polygon: Polygon, **kwargs) -> float:
    """Compute the eccentricity of a polygon.

    Note:
        Eccentricity (sometimes ellipticity) measures how far the object is
        from an ellipse. It is defined as the ratio of the length of the minor
        axis to the length of the major axis of an object. The closer the
        object is to an ellipse, the closer the eccentricity is to 1
        - [Wirth](http://www.cyto.purdue.edu/cdroms/micro2/content/education/wirth10.pdf)

    **Eccentricity:**
    $$
    \\sqrt{1 - \\frac{\\text{minor axis}^2}{\\text{major axis}^2}}
    $$

    Parameters:
        polygon (Polygon):
            Input shapely polygon object.

    Returns:
        float:
            The eccentricity value of a polygon between 0-1.
    """
    mrr = polygon.minimum_rotated_rectangle.exterior.coords
    major_ax, minor_ax = axis_len(mrr)
    eccentricity = np.sqrt(1 - (minor_ax**2 / major_ax**2))
    return eccentricity