biapy.data.generators.pair_data_2D_generator

2D paired image and mask data generator for BiaPy.

This module provides the Pair2DImageDataGenerator class, which generates batches of 2D images and their corresponding masks with on-the-fly augmentation.

class biapy.data.generators.pair_data_2D_generator.Pair2DImageDataGenerator(**kwars)[source]

Bases: PairBaseDataGenerator

Custom 2D data generator to transform paired image and mask data.

save_aug_samples(img: ndarray[tuple[int, ...], dtype[_ScalarType_co]], mask: ndarray[tuple[int, ...], dtype[_ScalarType_co]], orig_images: Dict, i: int, pos: int, out_dir: str)[source]

Save transformed samples in order to check the generator.

Parameters:
  • img (3D Numpy array) – Image to use as sample. E.g. (y, x, channels).

  • mask (3D Numpy array) – Mask to use as sample. E.g. (y, x, channels).

  • orig_images (dict) – Dict where the original image and mask are saved in “o_x” and “o_y”, respectively.

  • i (int) – Number of the sample within the transformed ones.

  • pos (int) – Number of the sample within the dataset.

  • out_dir (str) – Directory to save the images.