def test_mirror_horizontal_image():
    image = Image(
        np.array([[1., 2., 3., 4.], [5., 6., 7., 8.], [9., 10., 11., 12.]]))
    image.landmarks['temp'] = PointCloud(
        np.array([[1., 1.], [1., 2.], [2., 1.], [2., 2.]]))
    mirrored_img = image.mirror(axis=0)
    assert_allclose(
        mirrored_img.pixels,
        np.array([[[9., 10., 11., 12.], [5., 6., 7., 8.], [1., 2., 3., 4.]]]))
    assert_allclose(mirrored_img.landmarks['temp'].lms.points,
                    np.array([[1., 1.], [1., 2.], [0., 1.], [0., 2.]]))
def test_mirror_vertical_image():
    image = Image(
        np.array([[1., 2., 3., 4.], [5., 6., 7., 8.], [9., 10., 11., 12.]]))
    image.landmarks['temp'] = PointCloud(
        np.array([[1., 0.], [1., 1.], [2., 1.], [2., 2.]]))
    mirrored_img = image.mirror()
    assert_allclose(
        mirrored_img.pixels,
        np.array([[[4., 3., 2., 1.], [8., 7., 6., 5.], [12., 11., 10., 9.]]]))
    assert_allclose(mirrored_img.landmarks['temp'].lms.points,
                    np.array([[1., 3.], [1., 2.], [2., 2.], [2., 1.]]))
Exemplo n.º 3
0
def test_mirror_vertical_image():
    image = Image(np.array([[1., 2., 3., 4.],
                            [5., 6., 7., 8.],
                            [9., 10., 11., 12.]]))
    image.landmarks['temp'] = PointCloud(np.array([[1., 0.], [1., 1.],
                                                   [2., 1.], [2., 2.]]))
    mirrored_img = image.mirror()
    assert_allclose(mirrored_img.pixels,
                    np.array([[[4., 3., 2., 1.],
                               [8., 7., 6., 5.],
                               [12., 11., 10., 9.]]]))
    assert_allclose(mirrored_img.landmarks['temp'].points,
                    np.array([[1., 3.], [1., 2.], [2., 2.], [2., 1.]]))
Exemplo n.º 4
0
def test_mirror_horizontal_image():
    image = Image(np.array([[1., 2., 3., 4.],
                            [5., 6., 7., 8.],
                            [9., 10., 11., 12.]]))
    image.landmarks['temp'] = PointCloud(np.array([[1., 1.], [1., 2.],
                                                   [2., 1.], [2., 2.]]))
    mirrored_img = image.mirror(axis=0)
    assert_allclose(mirrored_img.pixels,
                    np.array([[[9., 10., 11., 12.],
                               [5., 6., 7., 8.],
                               [1., 2., 3., 4.]]]))
    assert_allclose(mirrored_img.landmarks['temp'].points,
                    np.array([[1., 1.], [1., 2.], [0., 1.], [0., 2.]]))
Exemplo n.º 5
0
def test_mirror_vertical_image():
    image = Image(
        np.array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0],
                  [9.0, 10.0, 11.0, 12.0]]))
    image.landmarks["temp"] = PointCloud(
        np.array([[1.0, 0.0], [1.0, 1.0], [2.0, 1.0], [2.0, 2.0]]))
    mirrored_img = image.mirror()
    assert_allclose(
        mirrored_img.pixels,
        np.array([[[4.0, 3.0, 2.0, 1.0], [8.0, 7.0, 6.0, 5.0],
                   [12.0, 11.0, 10.0, 9.0]]]),
    )
    assert_allclose(
        mirrored_img.landmarks["temp"].points,
        np.array([[1.0, 3.0], [1.0, 2.0], [2.0, 2.0], [2.0, 1.0]]),
    )