当前位置: 首页>>代码示例>>Python>>正文


Python image.BooleanImage类代码示例

本文整理汇总了Python中menpo.image.BooleanImage的典型用法代码示例。如果您正苦于以下问题:Python BooleanImage类的具体用法?Python BooleanImage怎么用?Python BooleanImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BooleanImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_booleanimage_copy

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))
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:10,代码来源:test_image_copy.py

示例2: test_warp_to_mask_boolean

def test_warp_to_mask_boolean():
    b = BooleanImage.init_blank((10, 10))
    b.pixels[:, :5] = False
    template_mask = BooleanImage.init_blank((10, 10))
    template_mask.pixels[:5, :] = False
    t = Affine.init_identity(2)
    warped_mask = b.warp_to_mask(template_mask, t)
    assert(type(warped_mask) == BooleanImage)
    result = template_mask.pixels.copy()
    result[:, :5] = False
    assert(np.all(result == warped_mask.pixels))
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:11,代码来源:image_warp_test.py

示例3: rasterize_barycentric_coordinate_images

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))
开发者ID:HaoyangWang,项目名称:menpo3d,代码行数:15,代码来源:cpu.py

示例4: test_mask_true_indices

def test_mask_true_indices():
    mask = BooleanImage.blank((64, 14, 51), fill=False)
    mask.mask[0, 2, 5] = True
    mask.mask[5, 13, 4] = True
    true_indices = mask.true_indices
    true_indices_test = np.array([[0, 2, 5], [5, 13, 4]])
    assert_equal(true_indices, true_indices_test)
开发者ID:ikassi,项目名称:menpo,代码行数:7,代码来源:image_test.py

示例5: test_sample_booleanimage

def test_sample_booleanimage():
    im = BooleanImage.init_blank((100, 100))
    im.pixels[0, 1, 0] = False
    p = PointCloud(np.array([[0, 0], [1, 0]]))

    arr = im.sample(p)
    assert_allclose(arr, [[True, False]])
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:7,代码来源:image_warp_test.py

示例6: test_boolean_image_from_vector_no_copy_raises

def test_boolean_image_from_vector_no_copy_raises():
    vector = np.zeros(16, dtype=np.bool)
    image = BooleanImage.blank((4, 4))
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        image.from_vector(vector[::-1], copy=False)
        assert len(w) == 1
开发者ID:Amos-zq,项目名称:menpo,代码行数:7,代码来源:image_test.py

示例7: test_mask_false_indices

def test_mask_false_indices():
    mask = BooleanImage.blank((64, 14, 51), fill=True)
    mask.mask[0, 2, 5] = False
    mask.mask[5, 13, 4] = False
    false_indices = mask.false_indices
    false_indices_test = np.array([[0, 2, 5], [5, 13, 4]])
    assert_equal(false_indices, false_indices_test)
开发者ID:ikassi,项目名称:menpo,代码行数:7,代码来源:image_test.py

示例8: test_boolean_image_constrain_landmarks

def test_boolean_image_constrain_landmarks():
    mask = BooleanImage.init_blank((10, 10), fill=False)
    mask.landmarks['test'] = PointCloud(
        np.array([[1, 1], [8, 1], [8, 8], [1, 8]]))
    new_mask = mask.constrain_to_landmarks('test')
    assert_allclose(new_mask.pixels[1:-1, 1:-1], True)
    assert new_mask.n_true() == 64
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:7,代码来源:test_boolean_image_constrain.py

示例9: test_boolean_image_constrain_pointcloud_convex_hull

def test_boolean_image_constrain_pointcloud_convex_hull():
    mask = BooleanImage.init_blank((10, 10), fill=False)
    pc = PointCloud(np.array([[1, 1], [8, 1], [8, 8], [1, 8]]))
    new_mask = mask.constrain_to_pointcloud(pc,
                                            point_in_pointcloud='convex_hull')
    assert_allclose(new_mask.pixels[:, 2:-1, 2:-1], True)
    # Points on the boundary are OUTSIDE
    assert new_mask.n_true() == 56
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:8,代码来源:test_boolean_image_constrain.py

示例10: test_mask_n_true_n_false

def test_mask_n_true_n_false():
    mask = BooleanImage.blank((64, 14), fill=False)
    assert_equal(mask.n_true, 0)
    assert_equal(mask.n_false, 64 * 14)
    mask.mask[0, 0] = True
    mask.mask[9, 13] = True
    assert_equal(mask.n_true, 2)
    assert_equal(mask.n_false, 64 * 14 - 2)
开发者ID:ikassi,项目名称:menpo,代码行数:8,代码来源:image_test.py

示例11: test_warp_to_mask_masked_image_all_true

def test_warp_to_mask_masked_image_all_true():
    img = MaskedImage.init_blank((10, 10), fill=2.5)

    template_mask = BooleanImage.init_blank((10, 10), fill=False)
    template_mask.pixels[:, :5, :5] = True
    t = Affine.init_identity(2)
    warped_img = img.warp_to_mask(template_mask, t)
    assert(type(warped_img) == MaskedImage)
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:8,代码来源:image_warp_test.py

示例12: test_boolean_bounds_false

def test_boolean_bounds_false():
    mask = BooleanImage.blank((8, 8), fill=True)
    mask.pixels[1, 2] = False
    mask.pixels[5, 4] = False
    mask.pixels[3:2, 3] = False
    min_b, max_b = mask.bounds_false()
    assert(np.all(min_b == np.array([1, 2])))
    assert(np.all(max_b == np.array([5, 4])))
开发者ID:Amos-zq,项目名称:menpo,代码行数:8,代码来源:image_test.py

示例13: test_zoom_booleanimage

def test_zoom_booleanimage():
    im = BooleanImage.init_blank((100, 100))
    im.pixels[0, 0, :] = False
    im.pixels[0, -1, :] = False
    im.pixels[0, :, 0] = False
    im.pixels[0, :, -1] = False

    zim = im.zoom(1.2)
    assert np.all(zim.pixels)
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:9,代码来源:image_warp_test.py

示例14: test_mask_true_bounding_extent

def test_mask_true_bounding_extent():
    mask = BooleanImage.blank((64, 14, 51), fill=False)
    mask.mask[0, 13, 5] = True
    mask.mask[5, 2, 4] = True
    tbe = mask.bounds_true()
    true_extends_mins = np.array([0, 2, 4])
    true_extends_maxs = np.array([5, 13, 5])
    assert_equal(tbe[0], true_extends_mins)
    assert_equal(tbe[1], true_extends_maxs)
开发者ID:ikassi,项目名称:menpo,代码行数:9,代码来源:image_test.py

示例15: test_warp_to_mask_masked_image

def test_warp_to_mask_masked_image():
    mask = BooleanImage.blank((10, 10))
    # make a funny mask on the original image
    mask.pixels[2:, :] = False
    img = MaskedImage.blank((10, 10), n_channels=2, mask=mask)
    img.pixels[...] = 2.5
    template_mask = BooleanImage.blank((10, 10), fill=False)
    template_mask.pixels[:5, :5] = True
    t = Affine.identity(2)
    warped_img = img.warp_to_mask(template_mask, t)
    assert(type(warped_img) == MaskedImage)
    result = Image.blank((10, 10), n_channels=2).pixels
    result[:5, :5, :] = 2.5
    result_mask = BooleanImage.blank((10, 10), fill=False).pixels
    result_mask[:2, :5] = True
    assert(warped_img.n_true_pixels() == 10)
    assert(np.all(result == warped_img.pixels))
    assert(np.all(result_mask == warped_img.mask.pixels))
开发者ID:Amos-zq,项目名称:menpo,代码行数:18,代码来源:image_warp_test.py


注:本文中的menpo.image.BooleanImage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。