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

Python image.Image类代码示例

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

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



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

示例1: test_rotate_image_90_180

def test_rotate_image_90_180():
    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.]]))
    # rotate 90 degrees
    rotated_img = image.rotate_ccw_about_centre(theta=90, order=0)
    rotated_img.landmarks['temp'] = rotated_img.landmarks['temp'].constrain_to_bounds(
        rotated_img.bounds())
    assert_allclose(rotated_img.pixels, np.array([[[4., 8., 12.],
                                                   [3., 7., 11.],
                                                   [2., 6., 10.],
                                                   [1., 5., 9.]]]))
    assert_almost_equal(rotated_img.landmarks['temp'].points,
                        np.array([[2., 1.], [1., 1.], [2., 2.], [1., 2.]]))

    # rotate 180 degrees
    rotated_img = image.rotate_ccw_about_centre(theta=180, order=0)
    rotated_img.landmarks['temp'] = rotated_img.landmarks['temp'].constrain_to_bounds(
        rotated_img.bounds())
    assert_allclose(rotated_img.pixels, np.array([[[12., 11., 10., 9.],
                                                   [8., 7., 6., 5.],
                                                   [4., 3., 2., 1.]]]))
    assert_almost_equal(rotated_img.landmarks['temp'].points,
                        np.array([[1., 2.], [1., 1.], [0., 2.], [0., 1.]]))
开发者ID:grigorisg9gr,项目名称:menpo,代码行数:26,代码来源:image_warp_test.py


示例2: test_image_clip_pixels_cutom_max_uint

def test_image_clip_pixels_cutom_max_uint():
    pixels = (np.random.rand(3, 10, 20) * 255).astype(np.uint8)
    # add the noise of increased values
    pixels[0, 0, 0] = 255
    image = Image(pixels, copy=False)
    image2 = image.clip_pixels(maximum=200)
    assert(image2.pixels.max() <= 200)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:7,代码来源:test_image.py


示例3: test_image_gradient_sanity

def test_image_gradient_sanity():
    # Only a sanity check - does it run and generate sensible output?
    image = Image(np.zeros([120, 120, 3]))
    new_image = image.gradient()
    assert(type(new_image) == Image)
    assert(new_image.shape == image.shape)
    assert(new_image.n_channels == image.n_channels * 2)
开发者ID:Amos-zq,项目名称:menpo,代码行数:7,代码来源:image_test.py


示例4: test_texturedtrimesh_copy

def test_texturedtrimesh_copy():
    points = np.ones([10, 3])
    tcoords = np.ones([10, 3])
    trilist = np.ones([10, 3])
    landmarks = PointCloud(np.ones([3, 3]), copy=False)
    landmarks_im = PointCloud(np.ones([3, 2]), copy=False)
    pixels = np.ones([10, 10, 1])
    texture = Image(pixels, copy=False)
    texture.landmarks['test_im'] = landmarks_im

    ttmesh = TexturedTriMesh(points, tcoords, texture, trilist=trilist,
                             copy=False)
    ttmesh.landmarks['test'] = landmarks
    ttmesh_copy = ttmesh.copy()

    assert (not is_same_array(ttmesh_copy.points, ttmesh.points))
    assert (not is_same_array(ttmesh_copy.trilist, ttmesh.trilist))
    assert (not is_same_array(ttmesh_copy.tcoords.points,
                              ttmesh.tcoords.points))
    assert (not is_same_array(ttmesh_copy.texture.pixels,
                              ttmesh.texture.pixels))
    assert (not is_same_array(
        ttmesh_copy.texture.landmarks['test_im'].lms.points,
        ttmesh.texture.landmarks['test_im'].lms.points))
    assert (not is_same_array(ttmesh_copy.landmarks['test'].lms.points,
                              ttmesh.landmarks['test'].lms.points))
开发者ID:Amos-zq,项目名称:menpo,代码行数:26,代码来源:trimesh_copy_test.py


示例5: test_image_from_vector_inplace_no_copy_warning

def test_image_from_vector_inplace_no_copy_warning():
        pixels = np.random.rand(10, 20, 2)
        pixels2 = np.random.rand(10, 20, 2)
        image = Image(pixels)
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            image.from_vector_inplace(pixels2.ravel()[::-1], copy=False)
            assert len(w) == 1
开发者ID:Amos-zq,项目名称:menpo,代码行数:8,代码来源:image_test.py


示例6: test_as_greyscale_average

def test_as_greyscale_average():
    ones = np.ones([3, 120, 120])
    image = Image(ones, copy=True)
    image.pixels[0].fill(0.5)
    new_image = image.as_greyscale(mode='average')
    assert (new_image.shape == image.shape)
    assert (new_image.n_channels == 1)
    assert_allclose(new_image.pixels[0], ones[0] * 0.83333333)
开发者ID:HaoyangWang,项目名称:menpo,代码行数:8,代码来源:image_test.py


示例7: test_normalize_std_image

def test_normalize_std_image():
    pixels = np.ones((3, 120, 120))
    pixels[0] = 0.5
    pixels[1] = 0.2345
    image = Image(pixels)
    image.normalize_std_inplace()
    assert_allclose(np.mean(image.pixels), 0, atol=1e-10)
    assert_allclose(np.std(image.pixels), 1)
开发者ID:OlivierML,项目名称:menpo,代码行数:8,代码来源:image_test.py


示例8: test_normalize_norm_image

def test_normalize_norm_image():
    pixels = np.ones((3, 120, 120))
    pixels[0] = 0.5
    pixels[1] = 0.2345
    image = Image(pixels)
    new_image = image.normalize_norm()
    assert_allclose(np.mean(new_image.pixels), 0, atol=1e-10)
    assert_allclose(np.linalg.norm(new_image.pixels), 1)
开发者ID:HaoyangWang,项目名称:menpo,代码行数:8,代码来源:image_test.py


示例9: test_normalize_norm_image

def test_normalize_norm_image():
    pixels = np.ones((120, 120, 3))
    pixels[..., 0] = 0.5
    pixels[..., 1] = 0.2345
    image = Image(pixels)
    image.normalize_norm_inplace()
    assert_allclose(np.mean(image.pixels), 0, atol=1e-10)
    assert_allclose(np.linalg.norm(image.pixels), 1)
开发者ID:Amos-zq,项目名称:menpo,代码行数:8,代码来源:image_test.py


示例10: test_copy_landmarks_and_path_with_no_lms_path

def test_copy_landmarks_and_path_with_no_lms_path():
    img = Image.init_blank((5, 5))
    new_img = Image.init_blank((5, 5))
    copy_landmarks_and_path(img, new_img)
    assert not hasattr(img, "path")
    assert not hasattr(new_img, "path")
    assert not img.has_landmarks
    assert not new_img.has_landmarks
开发者ID:nontas,项目名称:menpo,代码行数:8,代码来源:copy_landmarks_and_path_test.py


示例11: test_as_greyscale_luminosity

def test_as_greyscale_luminosity():
    ones = np.ones([3, 120, 120])
    image = Image(ones, copy=True)
    image.pixels[0].fill(0.5)
    new_image = image.as_greyscale(mode="luminosity")
    assert new_image.shape == image.shape
    assert new_image.n_channels == 1
    assert_allclose(new_image.pixels[0], ones[0] * 0.850532)
开发者ID:nontas,项目名称:menpo,代码行数:8,代码来源:image_test.py


示例12: test_image_copy

def test_image_copy():
    pixels = np.ones([1, 10, 10])
    landmarks = PointCloud(np.ones([3, 2]), copy=False)
    im = Image(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


示例13: test_normalize_norm_image

def test_normalize_norm_image():
    pixels = np.ones((3, 120, 120))
    pixels[0] = 0.5
    pixels[1] = 0.2345
    image = Image(pixels)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        new_image = image.normalize_norm()
    assert_allclose(np.mean(new_image.pixels), 0, atol=1e-10)
    assert_allclose(np.linalg.norm(new_image.pixels), 1)
开发者ID:dvdm,项目名称:menpo,代码行数:10,代码来源:image_test.py


示例14: test_normalize_std_image_per_channel

def test_normalize_std_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 9
    pixels[0] += -3
    pixels[2] /= 140
    image = Image(pixels)
    image.normalize_std_inplace(mode='per_channel')
    assert_allclose(
        np.mean(image.as_vector(keep_channels=True), axis=1), 0, atol=1e-10)
    assert_allclose(
        np.std(image.as_vector(keep_channels=True), axis=1), 1)
开发者ID:OlivierML,项目名称:menpo,代码行数:11,代码来源:image_test.py


示例15: test_normalize_norm_image_per_channel

def test_normalize_norm_image_per_channel():
    pixels = np.random.randn(120, 120, 3)
    pixels[..., 1] *= 17
    pixels[..., 0] += -114
    pixels[..., 2] /= 30
    image = Image(pixels)
    image.normalize_norm_inplace(mode='per_channel')
    assert_allclose(
        np.mean(image.as_vector(keep_channels=True), axis=0), 0, atol=1e-10)
    assert_allclose(
        np.linalg.norm(image.as_vector(keep_channels=True), axis=0), 1)
开发者ID:Amos-zq,项目名称:menpo,代码行数:11,代码来源:image_test.py


示例16: 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


示例17: test_image_clip_pixels_cutom_max

def test_image_clip_pixels_cutom_max():
    pixels = np.random.rand(3, 10, 20)
    # add the noise of increased values
    pixels *= 2.0
    pixels[0, 0, 0] = 3.0
    pixels[0, 0, 1] = - 0.1
    image = Image(pixels, copy=False)
    assert(image.pixels.max() > 1.0)
    image2 = image.clip_pixels(maximum=0.9)
    assert(image2.pixels.max() <= 0.9)
    assert(image2.pixels.min() >= 0.0)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:11,代码来源:test_image.py


示例18: test_normalize_norm_image_per_channel

def test_normalize_norm_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 17
    pixels[0] += -114
    pixels[2] /= 30
    image = Image(pixels)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        new_image = image.normalize_norm(mode="per_channel")
    assert_allclose(np.mean(new_image.as_vector(keep_channels=True), axis=1), 0, atol=1e-10)
    assert_allclose(np.linalg.norm(new_image.as_vector(keep_channels=True), axis=1), 1)
开发者ID:nontas,项目名称:menpo,代码行数:11,代码来源:image_test.py


示例19: test_normalize_norm_image_per_channel

def test_normalize_norm_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 17
    pixels[0] += -114
    pixels[2] /= 30
    image = Image(pixels)
    new_image = image.normalize_norm(mode='per_channel')
    assert_allclose(
        np.mean(new_image.as_vector(keep_channels=True), axis=1), 0,
        atol=1e-10)
    assert_allclose(
        np.linalg.norm(new_image.as_vector(keep_channels=True), axis=1), 1)
开发者ID:HaoyangWang,项目名称:menpo,代码行数:12,代码来源:image_test.py


示例20: test_mirror_vertical_image

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python image.MaskedImage类代码示例发布时间:2022-05-27
下一篇:
Python image.BooleanImage类代码示例发布时间: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