medpy.filter.label.fit_labels_to_mask#
- medpy.filter.label.fit_labels_to_mask(label_image, mask)[source]#
Reduces a label images by overlaying it with a binary mask and assign the labels either to the mask or to the background. The resulting binary mask is the nearest expression the label image can form of the supplied binary mask.
- Parameters:
- label_imagearray_like
A nD label map.
- maskarray_like
A mask image, i.e., a binary image with False for background and True for foreground.
- Returns:
- best_fitndarray
The best fit of the labels to the mask.
- Raises:
- ValueError
If
label_image
andmask
are not of the same shape.