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


Python Similarity.apply方法代码示例

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


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

示例1: test_basic_2d_similarity

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

示例2: test_align_2d_similarity

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

示例3: test_align_2d_similarity_set_h_matrix_raises_notimplemented_error

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


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