• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python image.BooleanImage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_init_from_rolled_channels_masked

def test_init_from_rolled_channels_masked():
    p = np.empty([50, 60, 3])
    example_mask = BooleanImage.init_blank((50, 60), fill=False)
    example_mask.pixels[0, :6, :6] = True

    im = MaskedImage.init_from_rolled_channels(p, mask=example_mask)
    assert im.n_channels == 3
    assert im.height == 50
    assert im.width == 60
    assert im.mask.n_true() == 36
开发者ID:HaoyangWang,项目名称:menpo,代码行数:10,代码来源:image_masked_test.py


示例17: test_warp_to_mask_masked_image

def test_warp_to_mask_masked_image():
    mask = BooleanImage.init_blank((15, 15))
    # make a truncated mask on the original image
    mask.pixels[0, -1, -1] = False
    img = MaskedImage.init_blank((15, 15), n_channels=2, mask=mask,
                                 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)

    result = Image.init_blank((10, 10), n_channels=2).pixels
    result[:, :5, :5] = 2.5
    result_mask = BooleanImage.init_blank((10, 10), fill=False).pixels
    result_mask[:, :5, :5] = True
    assert(warped_img.n_true_pixels() == 25)
    assert_allclose(result, warped_img.pixels)
    assert_allclose(result_mask, warped_img.mask.pixels)
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:19,代码来源:image_warp_test.py


示例18: test_constrain_mask_to_landmarks_pwa

def test_constrain_mask_to_landmarks_pwa():
    img = MaskedImage.init_blank((10, 10))
    img.landmarks['box'] = PointCloud(np.array([[0.0, 0.0], [5.0, 0.0],
                                                [5.0, 5.0], [0.0, 5.0]]))
    img.constrain_mask_to_landmarks(group='box')

    example_mask = BooleanImage.init_blank((10, 10), fill=False)
    example_mask.pixels[0, :6, :6] = True
    assert(img.mask.n_true() == 36)
    assert_allclose(img.mask.pixels, example_mask.pixels)
开发者ID:OlivierML,项目名称:menpo,代码行数:10,代码来源:image_masked_test.py


示例19: test_constrain_mask_to_landmarks_convex_hull

def test_constrain_mask_to_landmarks_convex_hull():
    img = MaskedImage.init_blank((10, 10))
    img.landmarks['box'] = PointCloud(np.array([[0., 0.], [5., 0.],
                                                [5., 5.], [0., 5.]]))
    img.constrain_mask_to_landmarks(group='box',
                                    point_in_pointcloud='convex_hull')
    example_mask = BooleanImage.init_blank((10, 10), fill=False)
    example_mask.pixels[0, :6, 1:6] = True
    assert(img.mask.n_true() == 30)
    assert_allclose(img.mask.pixels, example_mask.pixels)
开发者ID:OlivierML,项目名称:menpo,代码行数:10,代码来源:image_masked_test.py


示例20: test_warp_to_mask_image

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python image.Image类代码示例发布时间:2022-05-27
下一篇:
Python jsonutils.dumps函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap