Exemplo n.º 1
0
def test_as_greyscale_average():
    ones = np.ones([3, 120, 120])
    image = Image(ones, copy=True)
    image.pixels[0].fill(0.5)
    new_image = image.as_greyscale(mode='average')
    assert (new_image.shape == image.shape)
    assert (new_image.n_channels == 1)
    assert_allclose(new_image.pixels[0], ones[0] * 0.83333333)
Exemplo n.º 2
0
def test_as_greyscale_average():
    ones = np.ones([3, 120, 120])
    image = Image(ones, copy=True)
    image.pixels[0].fill(0.5)
    new_image = image.as_greyscale(mode="average")
    assert new_image.shape == image.shape
    assert new_image.n_channels == 1
    assert_allclose(new_image.pixels[0], ones[0] * 0.83333333)
Exemplo n.º 3
0
def test_as_greyscale_luminosity():
    ones = np.ones([3, 120, 120])
    image = Image(ones, copy=True)
    image.pixels[0].fill(0.5)
    new_image = image.as_greyscale(mode='luminosity')
    assert (new_image.shape == image.shape)
    assert (new_image.n_channels == 1)
    assert_allclose(new_image.pixels[0], ones[0] * 0.850532)
Exemplo n.º 4
0
def test_as_greyscale_luminosity():
    ones = np.ones([3, 120, 120])
    image = Image(ones, copy=True)
    image.pixels[0].fill(0.5)
    new_image = image.as_greyscale(mode="luminosity")
    assert new_image.shape == image.shape
    assert new_image.n_channels == 1
    assert_allclose(new_image.pixels[0], ones[0] * 0.850532)
Exemplo n.º 5
0
def test_as_greyscale_channels():
    image = Image(np.random.randn(3, 120, 120), copy=False)
    new_image = image.as_greyscale(mode='channel', channel=0)
    assert (new_image.shape == image.shape)
    assert (new_image.n_channels == 1)
    assert_allclose(new_image.pixels[0], image.pixels[0])
Exemplo n.º 6
0
def test_as_greyscale_channels():
    image = Image(np.random.randn(3, 120, 120), copy=False)
    new_image = image.as_greyscale(mode="channel", channel=0)
    assert new_image.shape == image.shape
    assert new_image.n_channels == 1
    assert_allclose(new_image.pixels[0], image.pixels[0])