Reduce quality by downscale then upscale. scale_min and scale_max control factor. Simulates resolution or compression loss.
This transform simulates the effect of a low-resolution image by first downscaling the image to a lower resolution and then upscaling it back to its original size. This process introduces loss of detail and can be used to simulate low-quality images or to test the robustness of models to different image resolutions.
scale_rangeRange for the downscaling factor. Should be two float values between 0 and 1, where the first value is less than or equal to the second. The actual downscaling factor will be randomly chosen from this range for each image. Lower values result in more aggressive downscaling. Default: (0.25, 0.25)
interpolation_pairA dictionary specifying the interpolation methods to use for downscaling and upscaling. Should contain two keys:
pProbability of applying the transform. Should be in the range [0, 1]. Default: 0.5
>>> import albumentations as A
>>> import cv2
>>> transform = A.Downscale(
... scale_range=(0.5, 0.75),
... interpolation_pair={'downscale': cv2.INTER_NEAREST, 'upscale': cv2.INTER_LINEAR},
... p=0.5
... )
>>> transformed = transform(image=image)
>>> downscaled_image = transformed['image']