ellipse_circumference
ellipse_circumference(mask, spacing=None)The circumference of the ellipse a region implies.
What a sonographer writes down: a fetal head circumference is the perimeter of the ellipse fitted to the skull, in millimetres, and no overlap score stands in for it - two masks of the same Dice can be 8 times apart in millimetres, depending on whether they are wrong in a ring or wrong in a ragged edge.
Takes the largest filled component first, because a prediction in two pieces has second moments that belong to neither.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| mask | np.ndarray | One image; read as a boolean through > 0. |
required |
| spacing | Any | Pixel size in millimetres, two numbers in the array’s own axis order. Unset returns pixels. Measure on the grid the spacing was recorded for: a prediction resized to a model’s input shape has pixels of a size nobody wrote down, so Engine.predict(space="source") is what this wants. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| float | The circumference, in millimetres when spacing was given and in pixels otherwise. |
Raises
| Name | Type | Description |
|---|---|---|
| MeasureError | If mask is not one image, or spacing is not two positive numbers. |
mask = np.zeros((41, 41), dtype=bool) rows, columns = np.ogrid[:41, :41] mask[((rows - 20) / 10) ** 2 + ((columns - 20) / 20) ** 2 <= 1] = True round(ellipse_circumference(mask, spacing=(0.5, 0.5))) # half-millimetre pixels 49