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


Python Translation.pseudoinverse方法代码示例

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


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

示例1: _recursive_procrustes

# 需要导入模块: from menpo.transform import Translation [as 别名]
# 或者: from menpo.transform.Translation import pseudoinverse [as 别名]
    def _recursive_procrustes(self):
        r"""
        Recursively calculates a procrustes alignment.
        """
        global mean_pointcloud, PointCloud, Similarity
        if mean_pointcloud is None or PointCloud is None or Similarity is None:
            from menpo.shape import mean_pointcloud, PointCloud
            from menpo.transform import Similarity
        if self.n_iterations > self.max_iterations:
            return False
        new_tgt = mean_pointcloud([PointCloud(t.aligned_source().points,
                                              copy=False)
                                   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:Amos-zq,项目名称:menpo,代码行数:36,代码来源:procrustes.py

示例2: chain_compose_after_inplace_chain_test

# 需要导入模块: from menpo.transform import Translation [as 别名]
# 或者: from menpo.transform.Translation import pseudoinverse [as 别名]
def chain_compose_after_inplace_chain_test():
    a = PointCloud(np.random.random([10, 2]))
    b = PointCloud(np.random.random([10, 2]))

    t = Translation([3, 4])
    s = Scale([4, 2])
    chain_1 = TransformChain([t, s])
    chain_2 = TransformChain([s.pseudoinverse(), t.pseudoinverse()])
    chain_1.compose_before_inplace(chain_2)

    points = PointCloud(np.random.random([10, 2]))
    chain_res = chain_1.apply(points)
    assert(np.allclose(points.points, chain_res.points))
开发者ID:HaoyangWang,项目名称:menpo,代码行数:15,代码来源:compose_chain_test.py

示例3: manual_no_op_chain_test

# 需要导入模块: from menpo.transform import Translation [as 别名]
# 或者: from menpo.transform.Translation import pseudoinverse [as 别名]
def manual_no_op_chain_test():
    points = PointCloud(np.random.random([10, 2]))
    t = Translation([3, 4])
    chain = TransformChain([t, t.pseudoinverse()])
    points_applied = chain.apply(points)
    assert(np.allclose(points_applied.points, points.points))
开发者ID:HaoyangWang,项目名称:menpo,代码行数:8,代码来源:compose_chain_test.py


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