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

Python transform.Similarity类代码示例

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

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



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

示例1: test_basic_2d_similarity

def test_basic_2d_similarity():
    linear_component = np.array([[2, -6],
                                 [6, 2]])
    translation_component = np.array([7, -8])
    h_matrix = np.eye(3, 3)
    h_matrix[:-1, :-1] = linear_component
    h_matrix[:-1, -1] = translation_component
    similarity = Similarity(h_matrix)
    x = np.array([[0, 1],
                  [1, 1],
                  [-1, -5],
                  [3, -5]])
    # transform x explicitly
    solution = np.dot(x, linear_component.T) + translation_component
    # transform x using the affine transform
    result = similarity.apply(x)
    # check that both answers are equivalent
    assert_allclose(solution, result)
    # create several copies of x
    x_copies = np.array([x, x, x, x, x, x, x, x])
    # transform all of copies at once using the affine transform
    results = similarity.apply(x_copies)
    # check that all copies have been transformed correctly
    for r in results:
        assert_allclose(solution, r)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:25,代码来源:test_homogeneous.py


示例2: test_align_2d_similarity

def test_align_2d_similarity():
    linear_component = np.array([[2, -6], [6, 2]])
    translation_component = np.array([7, -8])
    h_matrix = np.eye(3, 3)
    h_matrix[:-1, :-1] = linear_component
    h_matrix[:-1, -1] = translation_component
    similarity = Similarity(h_matrix)
    source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]]))
    target = similarity.apply(source)
    # estimate the transform from source and target
    estimate = AlignmentSimilarity(source, target)
    # check the estimates is correct
    assert_allclose(similarity.h_matrix, estimate.h_matrix)
开发者ID:kritsong,项目名称:menpo,代码行数:13,代码来源:h_align_test.py


示例3: test_align_2d_similarity_set_h_matrix_raises_notimplemented_error

def test_align_2d_similarity_set_h_matrix_raises_notimplemented_error():
    linear_component = np.array([[2, -6], [6, 2]])
    translation_component = np.array([7, -8])
    h_matrix = np.eye(3, 3)
    h_matrix[:-1, :-1] = linear_component
    h_matrix[:-1, -1] = translation_component
    similarity = Similarity(h_matrix)
    source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]]))
    target = similarity.apply(source)
    # estimate the transform from source to source
    estimate = AlignmentSimilarity(source, source)
    # and set the target
    estimate.set_h_matrix(h_matrix)
开发者ID:kritsong,项目名称:menpo,代码行数:13,代码来源:h_align_test.py


示例4: noisy_align

def noisy_align(source, target, noise_std=0.04, rotation=False):
    r"""
    Constructs and perturbs the optimal similarity transform between source
    to the target by adding white noise to its weights.

    Parameters
    ----------
    source: :class:`menpo.shape.PointCloud`
        The source pointcloud instance used in the alignment
    target: :class:`menpo.shape.PointCloud`
        The target pointcloud instance used in the alignment
    noise_std: float
        The standard deviation of the white noise

        Default: 0.04
    rotation: boolean
        If False the second parameter of the Similarity,
        which captures captures inplane rotations, is set to 0.

        Default:False

    Returns
    -------
    noisy_transform : :class: `menpo.transform.Similarity`
        The noisy Similarity Transform
    """
    transform = AlignmentSimilarity(source, target, rotation=rotation)
    parameters = transform.as_vector()
    parameter_range = np.hstack((parameters[:2], target.range()))
    noise = (parameter_range * noise_std *
             np.random.randn(transform.n_parameters))
    return Similarity.init_identity(source.n_dims).from_vector(parameters + noise)
开发者ID:VLAM3D,项目名称:alabortcvpr2015,代码行数:32,代码来源:utils.py


示例5: _recursive_procrustes

    def _recursive_procrustes(self):
        r"""
        Recursively calculates a procrustes alignment.
        """
        from menpo.shape import mean_pointcloud
        from menpo.transform import Similarity
        if self.n_iterations > self.max_iterations:
            return False
        new_tgt = mean_pointcloud([t.aligned_source.points
                                   for t in self.transforms])
        # rescale the new_target to be the same size as the original about
        # it's centre
        rescale = Similarity.identity(new_tgt.n_dims)

        s = UniformScale(self.initial_target_scale / new_tgt.norm(),
                         self.n_dims, skip_checks=True)
        t = Translation(-new_tgt.centre, skip_checks=True)
        rescale.compose_before_inplace(t)
        rescale.compose_before_inplace(s)
        rescale.compose_before_inplace(t.pseudoinverse)
        rescale.apply_inplace(new_tgt)
        # check to see if we have converged yet
        delta_target = np.linalg.norm(self.target.points - new_tgt.points)
        if delta_target < 1e-6:
            return True
        else:
            self.n_iterations += 1
            for t in self.transforms:
                t.set_target(new_tgt)
            self.target = new_tgt
            return self._recursive_procrustes()
开发者ID:yymath,项目名称:menpo,代码行数:31,代码来源:procrustes.py


示例6: test_similarity_2d_from_vector

def test_similarity_2d_from_vector():
    params = np.array([0.2, 0.1, 1, 2])
    homo = np.array([[params[0] + 1, -params[1], params[2]],
                     [params[1], params[0] + 1, params[3]],
                     [0, 0, 1]])

    sim = Similarity.init_identity(2).from_vector(params)

    assert_equal(sim.h_matrix, homo)
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:9,代码来源:test_homogeneous.py


示例7: test_similarity_jacobian_2d

def test_similarity_jacobian_2d():
    params = np.ones(4)
    t = Similarity.identity(2).from_vector(params)
    explicit_pixel_locations = np.array(
        [[0, 0],
        [0, 1],
        [0, 2],
        [1, 0],
        [1, 1],
        [1, 2]])
    dW_dp = t.d_dp(explicit_pixel_locations)
    assert_equal(dW_dp, sim_jac_solution2d)
开发者ID:dubzzz,项目名称:menpo,代码行数:12,代码来源:homogeneous_test.py


示例8: test_similarity_set_h_matrix_raises_notimplementederror

def test_similarity_set_h_matrix_raises_notimplementederror():
    s = Similarity(np.eye(3))
    s.set_h_matrix(s.h_matrix)
开发者ID:dubzzz,项目名称:menpo,代码行数:3,代码来源:homogeneous_test.py


示例9: test_similarity_2d_points_raises_dimensionalityerror

def test_similarity_2d_points_raises_dimensionalityerror():
    params = np.ones(4)
    t = Similarity.identity(2).from_vector(params)
    t.d_dp(np.ones([2, 3]))
开发者ID:dubzzz,项目名称:menpo,代码行数:4,代码来源:homogeneous_test.py


示例10: test_similarity_jacobian_3d_raises_dimensionalityerror

def test_similarity_jacobian_3d_raises_dimensionalityerror():
    t = Similarity(np.eye(4))
    t.d_dp(np.ones([2, 3]))
开发者ID:dubzzz,项目名称:menpo,代码行数:3,代码来源:homogeneous_test.py


示例11: test_similarity_identity_3d

def test_similarity_identity_3d():
    assert_allclose(Similarity.identity(3).h_matrix,
                    np.eye(4))
开发者ID:Amos-zq,项目名称:menpo,代码行数:3,代码来源:h_similarity_test.py


示例12: test_similarity_identity_2d

def test_similarity_identity_2d():
    assert_allclose(Similarity.init_identity(2).h_matrix,
                    np.eye(3))
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:3,代码来源:test_h_similarity.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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