def test_normalize_norm_channels(): pixels = np.arange(27, dtype=np.float).reshape([3, 3, 3]) image = Image(pixels, copy=False) new_image = normalize_norm(image, mode='per_channel') assert_allclose(np.linalg.norm(new_image.pixels[0]), 1.) assert_allclose(np.linalg.norm(new_image.pixels[1]), 1.) assert_allclose(np.linalg.norm(new_image.pixels[2]), 1.)
def test_normalize_norm_all(): pixels = np.arange(27, dtype=np.float).reshape([3, 3, 3]) image = Image(pixels, copy=False) new_image = normalize_norm(image, mode="all") assert_allclose(np.linalg.norm(new_image.pixels), 1.0)