def test_downscale(interpolation): img_float = np.random.rand(100, 100, 3) img_uint = (img_float * 255).astype("uint8") aug = A.Downscale(scale_min=0.5, scale_max=0.5, interpolation=interpolation, always_apply=True) for img in (img_float, img_uint): transformed = aug(image=img)["image"] func_applied = F.downscale(img, scale=0.5, interpolation=interpolation) np.testing.assert_almost_equal(transformed, func_applied)
def test_downscale_random(): img = np.random.rand(100, 100, 3) downscaled = F.downscale(img, scale=0.5) assert downscaled.shape == img.shape downscaled = F.downscale(img, scale=1) assert np.all(img == downscaled)
def test_downscale_ones(dtype): img = np.ones((100, 100, 3), dtype=dtype) downscaled = F.downscale(img, scale=0.5) assert np.all(downscaled == img)