segmetrics.contour
- class segmetrics.contour.ContourMeasure(*args, correspondance_function: Literal['min', 'max'] = 'min', **kwargs)
Bases:
ImageMeasureMixin,MeasureDefines a performance measure which is based on the spatial distances of binary volumes (images).
- class segmetrics.contour.Hausdorff(quantile: float = 1, **kwargs)
Bases:
ContourMeasureDefines the Hausdorff distsance between two binary images.
The Hausdorff distsance is the maximum Euclidean distance of the ground truth contour to the segmented contour. The Hausdorff distsance is not upper-bounded. Lower values correspond to better segmentation performance.
- Parameters:
quantile – Specifies the quantile of the Hausdorff distsance. The default
quantile=1corresponds to the Hausdorff distance described by Bamford (2003). Any other positive value forquantilecorresponds to the quantile method introduced by Rucklidge (1997).
References:
P. Bamford, “Empirical comparison of cell segmentation algorithms using an annotated dataset,” in Proc. Int. Conf. Image Proc., 1612 vol. 2, 2003, pp. II-1073–1076.
W. J. Rucklidge, “Efficiently locating objects using the Hausdorff distance.” International Journal of computer vision 24.3 (1997): 251-270.
- compute(actual: None) List[float]
Computes the values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).
- class segmetrics.contour.NSD(*args, correspondance_function: Literal['min', 'max'] = 'min', **kwargs)
Bases:
ContourMeasureDefines the normalized sum of distsances between two binary images.
Let \(R\) be the set of all image pixels corresponding to the ground truth segmentation, and \(S\) the set of those corresponding to the segmentation result. Moreover, let \(\operatorname{dist}_{\partial R} \left(x\right) = \min_{x' \in \partial R}\left\|x - x'\right\|\) be the Euclidean distance of an image point \(x\) to the contour \(\partial R\) of the ground truth segmentation \(R\). Then, the normalized sum of distances is defined as
\[\mathrm{NSD} = \sum_{x \in R \triangle S} \operatorname{dist}_{\partial R}\left(x\right) / \sum_{x \in R \cup S} \operatorname{dist}_{\partial R}\left(x\right),\]where \(R \triangle S = \left(R \setminus S\right) \cup \left(S \setminus R\right)\) is the symmetric difference of \(R\) and \(S\). \(\mathrm{NSD}\) attains values between \(0\) and \(1\). Lower values correspond to better segmentation performance.
- compute(actual: None) List[float]
Computes the values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).