Esempio n. 1
0
def rasterize_barycentric_coordinate_images(mesh, image_shape):
    h, w = image_shape
    yx, bcoords, tri_indices = rasterize_barycentric_coordinates(
        mesh, image_shape)

    tri_indices_img = np.zeros((1, h, w), dtype=int)
    bcoords_img = np.zeros((3, h, w))
    mask = np.zeros((h, w), dtype=np.bool)
    mask[yx[:, 0], yx[:, 1]] = True
    tri_indices_img[:, yx[:, 0], yx[:, 1]] = tri_indices
    bcoords_img[:, yx[:, 0], yx[:, 1]] = bcoords.T

    mask = BooleanImage(mask)
    return (MaskedImage(bcoords_img, mask=mask.copy(), copy=False),
            MaskedImage(tri_indices_img, mask=mask.copy(), copy=False))
Esempio n. 2
0
def rasterize_barycentric_coordinate_images(mesh, image_shape):
    h, w = image_shape
    yx, bcoords, tri_indices = rasterize_barycentric_coordinates(mesh,
                                                                 image_shape)

    tri_indices_img = np.zeros((1, h, w), dtype=int)
    bcoords_img = np.zeros((3, h, w))
    mask = np.zeros((h, w), dtype=np.bool)
    mask[yx[:, 0], yx[:, 1]] = True
    tri_indices_img[:, yx[:, 0], yx[:, 1]] = tri_indices
    bcoords_img[:, yx[:, 0], yx[:, 1]] = bcoords.T

    mask = BooleanImage(mask)
    return (MaskedImage(bcoords_img, mask=mask.copy(), copy=False),
            MaskedImage(tri_indices_img, mask=mask.copy(), copy=False))
Esempio n. 3
0
def test_booleanimage_copy():
    pixels = np.ones([10, 10], dtype=np.bool)
    landmarks = PointCloud(np.ones([3, 2]), copy=False)
    im = BooleanImage(pixels, copy=False)
    im.landmarks['test'] = landmarks
    im_copy = im.copy()

    assert (not is_same_array(im.pixels, im_copy.pixels))
    assert (not is_same_array(im_copy.landmarks['test'].points,
                              im.landmarks['test'].points))