Skip to content

solidity

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

Compute the solidity of a polygon.

Note

Solidity measures the density of an object. It is defined as the ratio of the area of an object to the area of a convex hull of the object. A value of 1 signifies a solid object, and a value less than 1 will signify an object having an irregular boundary, or containing holes. - Wirth

Solidity: $$ \frac{A_{poly}}{A_{convex}} $$

where \(A_{poly}\) is the area of the polygon and \(A_{convex}\) is the area of the convex hull.

Parameters:

Name Type Description Default
polygon Polygon

Input shapely polygon object.

required

Returns:

Name Type Description
float float

The solidity value of a polygon between 0-1.

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

    Note:
        Solidity measures the density of an object. It is defined as the
        ratio of the area of an object to the area of a convex hull of the
        object. A value of 1 signifies a solid object, and a value less than
        1 will signify an object having an irregular boundary, or containing
        holes.
        - [Wirth](http://www.cyto.purdue.edu/cdroms/micro2/content/education/wirth10.pdf)

    **Solidity:**
    $$
    \\frac{A_{poly}}{A_{convex}}
    $$

    where $A_{poly}$ is the area of the polygon and $A_{convex}$ is the area of the
    convex hull.

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

    Returns:
        float:
            The solidity value of a polygon between 0-1.
    """
    convex_area = polygon.convex_hull.area
    area = polygon.area

    return area / convex_area