本文整理汇总了Python中menpo.transform.Affine.apply方法的典型用法代码示例。如果您正苦于以下问题:Python Affine.apply方法的具体用法?Python Affine.apply怎么用?Python Affine.apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menpo.transform.Affine
的用法示例。
在下文中一共展示了Affine.apply方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_basic_2d_affine
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import apply [as 别名]
def test_basic_2d_affine():
linear_component = np.array([[1, -6],
[-3, 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
affine = Affine(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 = affine.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 = affine.apply(x_copies)
# check that all copies have been transformed correctly
for r in results:
assert_allclose(solution, r)
示例2: test_align_2d_affine
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import apply [as 别名]
def test_align_2d_affine():
linear_component = np.array([[1, -6], [-3, 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
affine = Affine(h_matrix)
source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]]))
target = affine.apply(source)
# estimate the transform from source and target
estimate = AlignmentAffine(source, target)
# check the estimates is correct
assert_allclose(affine.h_matrix, estimate.h_matrix)