dcnum.segm.segm_torch.torch_postproc
Attributes
Functions
|
Postprocess mask images from ML segmenters |
Module Contents
- dcnum.segm.segm_torch.torch_postproc.ndi
- dcnum.segm.segm_torch.torch_postproc.postprocess_masks(masks, original_image_shape: tuple[int, int])[source]
Postprocess mask images from ML segmenters
The transformation includes:
Revert the cropping and padding operations done in
preprocess_images()by padding with zeros and cropping.If the original image shape is larger than the mask image shape, also clear borders in an intermediate step (maks postprocessing using
Segmenter.process_labels()).
- Parameters:
masks (3d or 4d ndarray) – Mask data in shape (batch_size, 1, imagex_size, imagey_size) or (batch_size, imagex_size, imagey_size).
original_image_shape (tuple of (int, int)) – The required output mask shape for one event. This required for doing the inverse of what is done in
preprocess_images().
- Returns:
labels_proc – An integer array with the same dimensions as the original image data passed to
preprocess_images(). The shape of this array is (batch_size, original_image_shape[0], original_image_shape[1]).- Return type:
np.ndarray
Notes
This method is only called by the overarching logic when the preprocessing/model output produces images of different shape. It causes an obvious overhead that we want to avoid.