本文整理汇总了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()
示例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))
示例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))