Exemplo n.º 1
0
def test_normalize_std_image():
    pixels = np.ones((120, 120, 3))
    pixels[..., 0] = 0.5
    pixels[..., 1] = 0.2345
    image = Image(pixels)
    image.normalize_std_inplace()
    assert_allclose(np.mean(image.pixels), 0, atol=1e-10)
    assert_allclose(np.std(image.pixels), 1)
Exemplo n.º 2
0
def test_normalize_std_image():
    pixels = np.ones((120, 120, 3))
    pixels[..., 0] = 0.5
    pixels[..., 1] = 0.2345
    image = Image(pixels)
    image.normalize_std_inplace()
    assert_allclose(np.mean(image.pixels), 0, atol=1e-10)
    assert_allclose(np.std(image.pixels), 1)
Exemplo n.º 3
0
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(120, 120, 3)
    pixels[..., 1] *= 9
    pixels[..., 0] += -3
    pixels[..., 2] /= 140
    image = Image(pixels)
    image.normalize_std_inplace(mode='per_channel')
    assert_allclose(
        np.mean(image.as_vector(keep_channels=True), axis=0), 0, atol=1e-10)
    assert_allclose(
        np.std(image.as_vector(keep_channels=True), axis=0), 1)
Exemplo n.º 4
0
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(120, 120, 3)
    pixels[..., 1] *= 9
    pixels[..., 0] += -3
    pixels[..., 2] /= 140
    image = Image(pixels)
    image.normalize_std_inplace(mode='per_channel')
    assert_allclose(np.mean(image.as_vector(keep_channels=True), axis=0),
                    0,
                    atol=1e-10)
    assert_allclose(np.std(image.as_vector(keep_channels=True), axis=0), 1)