PixelDropout

Targets:
image
mask
bboxes
keypoints
volume
mask3d
Image Types:uint8, float32

Drops random pixels from the image.

This transform randomly sets pixels in the image to a specified value, effectively "dropping out" those pixels. It can be applied to both the image and its corresponding mask.

Arguments
dropout_prob
float
0.01

Probability of dropping out each pixel. Should be in the range [0, 1]. Default: 0.01

per_channel
bool
false

If True, the dropout mask will be generated independently for each channel. If False, the same dropout mask will be applied to all channels. Default: False

drop_value
tuple[float, ...] | float | None
0

Value to assign to the dropped pixels. If None, the value will be randomly sampled for each application: - For uint8 images: Random integer in [0, 255] - For float32 images: Random float in [0, 1] If a single number, that value will be used for all dropped pixels. If a sequence, it should contain one value per channel. Default: 0

mask_drop_value
tuple[float, ...] | float | None

Value to assign to dropped pixels in the mask. If None, the mask will remain unchanged. If a single number, that value will be used for all dropped pixels in the mask. If a sequence, it should contain one value per channel. Default: None

p
float
0.5

Probability of applying the transform. Should be in the range [0, 1]. Default: 0.5

Examples
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
>>> mask = np.random.randint(0, 2, (100, 100), dtype=np.uint8)
>>> transform = A.PixelDropout(dropout_prob=0.1, per_channel=True, p=1.0)
>>> result = transform(image=image, mask=mask)
>>> dropped_image, dropped_mask = result['image'], result['mask']
Notes
  • When applied to bounding boxes, this transform may cause some boxes to have zero area if all pixels within the box are dropped. Such boxes will be removed.
  • When applied to keypoints, keypoints that fall on dropped pixels will be removed if the keypoint processor is configured to remove invisible keypoints.