Ejemplo n.º 1
0
def test_load():
    image = Image("tests/images/lenna.png")
    assert image.loaded
    image = Image("tests/images/lenna.png", lazy=True)
    assert not image.loaded
    image.load()
    assert image.loaded
Ejemplo n.º 2
0
def test_compute():
    image = Image("tests/images/lenna.png", lazy=True)
    image = image.apply(GrayScale())
    assert image.pending.num_transforms() == 1
    computed = image.compute()
    assert computed.pending.num_transforms() == 0
    image.compute(in_place=True)
    assert image.pending.num_transforms() == 0
Ejemplo n.º 3
0
def test_image():
    image = Image("tests/images/lenna.png")
    assert image.array is not None
    image = Image("https://images.dog.ceo/breeds/komondor/n02105505_2699.jpg")
    assert image.array is not None
Ejemplo n.º 4
0
def test_apply():
    image = Image("tests/images/lenna.png")
    pipe = Pipeline([Blur(), GrayScale()])
    image2 = image.apply(Blur()).apply(GrayScale())
    image = image.apply(pipe)
    assert image == image2
Ejemplo n.º 5
0
def test_width():
    image = Image("tests/images/lenna.png")
    assert image.width == 512
Ejemplo n.º 6
0
def test_height():
    image = Image("tests/images/lenna.png")
    assert image.height == 512
Ejemplo n.º 7
0
def test_pending():
    image = Image("tests/images/lenna.png", lazy=True)
    image = image.apply(FilterChannels(channels=[0, 1]))
    image.apply(GrayScale(), in_place=True)
    assert image.pending.num_transforms() == 2