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


Python Similarity.init_identity方法代码示例

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


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

示例1: noisy_align

# 需要导入模块: from menpo.transform import Similarity [as 别名]
# 或者: from menpo.transform.Similarity import init_identity [as 别名]
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,代码行数:34,代码来源:utils.py

示例2: _recursive_procrustes

# 需要导入模块: from menpo.transform import Similarity [as 别名]
# 或者: from menpo.transform.Similarity import init_identity [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.init_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:OlivierML,项目名称:menpo,代码行数:36,代码来源:procrustes.py

示例3: test_similarity_2d_from_vector

# 需要导入模块: from menpo.transform import Similarity [as 别名]
# 或者: from menpo.transform.Similarity import init_identity [as 别名]
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,代码行数:11,代码来源:test_homogeneous.py

示例4: test_similarity_identity_3d

# 需要导入模块: from menpo.transform import Similarity [as 别名]
# 或者: from menpo.transform.Similarity import init_identity [as 别名]
def test_similarity_identity_3d():
    assert_allclose(Similarity.init_identity(3).h_matrix,
                    np.eye(4))
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:5,代码来源:test_h_similarity.py


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