def test_normalize_var_channels():
    pixels = np.arange(27, dtype=np.float).reshape([3, 3, 3])
    image = Image(pixels, copy=False)
    new_image = normalize_var(image, mode='per_channel')
    assert_allclose(np.var(new_image.pixels[0]),  0.15, atol=1e-5)
    assert_allclose(np.var(new_image.pixels[1]),  0.15, atol=1e-5)
    assert_allclose(np.var(new_image.pixels[2]),  0.15, atol=1e-5)
def test_normalize_var_all():
    pixels = np.arange(27, dtype=np.float).reshape([3, 3, 3])
    image = Image(pixels, copy=False)
    new_image = normalize_var(image, mode='all')
    assert_allclose(np.var(new_image.pixels),  0.01648, atol=1e-3)