Exemplo n.º 1
0
def test_merge():
    img = tf.merge(img1, img2)
    assert img.x_axis == img1.x_axis and img.y_axis == img1.y_axis
    chan = img.img.view([('r', 'uint8'), ('g', 'uint8'),
                         ('b', 'uint8'), ('a', 'uint8')])
    assert (chan['r'] == np.array([[127, 0], [0, 190]])).all()
    assert (chan['g'] == np.array([[127, 0], [0, 190]])).all()
    assert (chan['b'] == np.array([[0, 0], [0, 62]])).all()
    assert (chan['a'] == np.array([[127, 0], [127, 190]])).all()
    assert (tf.merge(img2, img1).img == img.img).all()
Exemplo n.º 2
0
def test_merge():
    img = tf.merge(img1, img2)
    assert (img.x_axis == img1.x_axis).all()
    assert (img.y_axis == img1.y_axis).all()
    chan = img.data.view([('r', 'uint8'), ('g', 'uint8'), ('b', 'uint8'),
                          ('a', 'uint8')])
    assert (chan['r'] == np.array([[127, 0], [0, 190]])).all()
    assert (chan['g'] == np.array([[127, 0], [0, 190]])).all()
    assert (chan['b'] == np.array([[0, 0], [0, 62]])).all()
    assert (chan['a'] == np.array([[127, 0], [127, 190]])).all()
    assert (tf.merge(img2, img1).data == img.data).all()
Exemplo n.º 3
0
def test_stack_merge_aligned_axis():
    # If/when non_aligned axis become supported, these can be removed
    img3 = tf.Image(np.arange(4, dtype='uint32').reshape((2, 2)),
                    x_axis=x_axis, y_axis=LinearAxis((1, 20)))
    img4 = tf.Image(np.arange(9, dtype='uint32').reshape((3, 3)),
                    x_axis=x_axis, y_axis=y_axis)
    with pytest.raises(NotImplementedError):
        tf.stack(img1, img3)
    with pytest.raises(NotImplementedError):
        tf.stack(img1, img4)
    with pytest.raises(NotImplementedError):
        tf.merge(img1, img3)
    with pytest.raises(NotImplementedError):
        tf.merge(img1, img4)