Skip to content

sphericity

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

Compute the sphericity of a polygon.

Note

Sphericity measures how close an object is to the shape of a “sphere”. It is defined as the ratio of the radius of the minimum inscribing circle to the radius of the minimum bounding circle.

Sphericity: $$ \frac{\text{MIR}}{\text{MBR}} $$

where \(\text{MIR}\) is the radius of the minimum inscribing circle radius and \(\text{MBR}\) is the radius of the minimum bounding radius.

Parameters:

Name Type Description Default
polygon Polygon

Input shapely polygon object.

required

Returns:

Name Type Description
float float

The sphericity value of a polygon.

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

    Note:
        Sphericity measures how close an object is to the shape of a “sphere”.
        It is defined as the ratio of the radius of the minimum inscribing circle
        to the radius of the minimum bounding circle.

    **Sphericity:**
    $$
    \\frac{\\text{MIR}}{\\text{MBR}}
    $$

    where $\\text{MIR}$ is the radius of the minimum inscribing circle radius and
    $\\text{MBR}$ is the radius of the minimum bounding radius.

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

    Returns:
        float:
            The sphericity value of a polygon.
    """
    _, _, ri = inscribing_circle(polygon)
    rc = shapely.minimum_bounding_radius(polygon)

    return ri / rc