← Back to all transforms

CoarseDropout

Description

CoarseDropout randomly drops out rectangular regions from the image and optionally,
    the corresponding regions in an associated mask, to simulate the occlusion and
    varied object sizes found in real-world settings. This transformation is an
    evolution of CutOut and RandomErasing, offering more flexibility in the size,
    number of dropout regions, and fill values.

    Args:
        num_holes_range (tuple[int, int]): Specifies the range (minimum and maximum)
            of the number of rectangular regions to zero out. This allows for dynamic
            variation in the number of regions removed per transformation instance.
        hole_height_range (tuple[ScalarType, ScalarType]): Defines the minimum and
            maximum heights of the dropout regions, providing variability in their vertical dimensions.
        hole_width_range (tuple[ScalarType, ScalarType]): Defines the minimum and
            maximum widths of the dropout regions, providing variability in their horizontal dimensions.
        fill_value (ColorType, Literal["random"]): Specifies the value used to fill the dropout regions.
            This can be a constant value, a tuple specifying pixel intensity across channels, or 'random'
            which fills the region with random noise.
        mask_fill_value (ColorType | None): Specifies the fill value for dropout regions in the mask.
            If set to `None`, the mask regions corresponding to the image dropout regions are left unchanged.


    Targets:
        image, mask, keypoints

    Image types:
        uint8, float32

    Reference:
        https://arxiv.org/abs/1708.04552
        https://github.com/uoguelph-mlrg/Cutout/blob/master/util/cutout.py
        https://github.com/aleju/imgaug/blob/master/imgaug/augmenters/arithmetic.py

    

Parameters

  • p: float (default: 0.5)
  • min_holes: int | None (default: null)
  • max_holes: int | None (default: null)
  • num_holes_range: tuple[int, int] (default: (1, 1))
  • min_height: int | float | None (default: null)
  • max_height: int | float | None (default: null)
  • hole_height_range: tuple[int | float, int | float] (default: (8, 8))
  • min_width: int | float | None (default: null)
  • max_width: int | float | None (default: null)
  • hole_width_range: tuple[int | float, int | float] (default: (8, 8))
  • fill_value: float | Sequence[float] | Literal['random'] (default: 0)
  • mask_fill_value: float | Sequence[float] | None (default: null)

Targets

  • Image
  • Mask
  • Keypoints

Try it out

Original Image (width = 484, height = 733):

Original

Transformed Image:

Transform not yet applied