← Back to all transforms
PixelDropout
Description
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. Args: dropout_prob (float): Probability of dropping out each pixel. Should be in the range [0, 1]. Default: 0.01 per_channel (bool): 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 (float | Sequence[float] | None): 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 (float | Sequence[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 of the mask. Note: Only applicable when per_channel=False. Default: None always_apply (bool): If True, the transform will always be applied. Default: False p (float): Probability of applying the transform. Should be in the range [0, 1]. Default: 0.5 Targets: image, mask, bboxes, keypoints Image types: uint8, float32 Note: - 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. - The 'per_channel' option is not supported for mask dropout. If you need to drop pixels in a multi-channel mask independently, consider applying this transform multiple times with per_channel=False. Example: >>> 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']
Parameters
- dropout_prob: float (default: 0.01)
- per_channel: bool (default: false)
- drop_value: float | tuple[float, float] | None (default: 0)
- mask_drop_value: float | tuple[float, float] | None (default: null)
- p: float (default: 0.5)
Targets
- Image
- Mask
- BBoxes
- Keypoints
Try it out
ⓘ