本文整理汇总了Python中menpo.transform.Affine.identity方法的典型用法代码示例。如果您正苦于以下问题:Python Affine.identity方法的具体用法?Python Affine.identity怎么用?Python Affine.identity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menpo.transform.Affine
的用法示例。
在下文中一共展示了Affine.identity方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_c_warp_gray
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_c_warp_gray():
target_transform = Affine.identity(2).from_vector(initial_params)
warped_im = gray_image.warp_to(template_mask, target_transform,
interpolator='c')
assert(warped_im.shape == gray_template.shape)
assert_allclose(warped_im.pixels, gray_template.pixels)
示例2: test_warp_multi
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_warp_multi():
rgb_image = mio.import_builtin_asset('takeo.ppm')
target_transform = Affine.identity(2).from_vector(initial_params)
warped_im = rgb_image.warp_to_mask(template_mask, target_transform)
assert(warped_im.shape == rgb_template.shape)
assert_allclose(warped_im.pixels, rgb_template.pixels)
示例3: residual_wrapper
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def residual_wrapper(residual, algorithm, interpolator, expected_error):
image, template, initial_params = setup_conditions(interpolator)
align_algorithm = algorithm(
template, residual, Affine.identity(2).from_vector(
initial_params))
fitting = align_algorithm.fit(image, initial_params)
transform = fitting.final_transform
rms_error = compute_fixed_error(transform)
assert_approx_equal(rms_error, expected_error)
示例4: setup_error
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def setup_error():
target_transform = Affine.identity(2).from_vector(target_params)
original_box = np.array([[0, 0],
[target_shape[0], 0],
[target_shape[0], target_shape[1]],
[0, target_shape[1]]]).T
target_pts = target_transform.apply(original_box.T)
return target_pts, original_box
示例5: test_warp_to_mask_image
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_warp_to_mask_image():
img = Image.blank((10, 10), n_channels=2)
img.pixels[:, :5, :] = 0.5
template_mask = BooleanImage.blank((10, 10))
template_mask.pixels[5:, :] = False
t = Affine.identity(2)
warped_img = img.warp_to_mask(template_mask, t)
assert(type(warped_img) == MaskedImage)
result = Image.blank((10, 10), n_channels=2).pixels
result[:5, :5, :] = 0.5
assert(np.all(result == warped_img.pixels))
示例6: test_warp_to_mask_boolean
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_warp_to_mask_boolean():
b = BooleanImage.blank((10, 10))
b.pixels[:, :5] = False
template_mask = BooleanImage.blank((10, 10))
template_mask.pixels[:5, :] = False
t = Affine.identity(2)
warped_mask = b.warp_to_mask(template_mask, t)
assert(type(warped_mask) == BooleanImage)
result = template_mask.pixels.copy()
result[:, :5] = False
assert(np.all(result == warped_mask.pixels))
示例7: test_affine_jacobian_2d_with_positions
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_affine_jacobian_2d_with_positions():
params = np.array([0, 0.1, 0.2, 0, 30, 70])
t = Affine.identity(2).from_vector(params)
explicit_pixel_locations = np.array(
[[0, 0],
[0, 1],
[0, 2],
[1, 0],
[1, 1],
[1, 2]])
dW_dp = t.d_dp(explicit_pixel_locations)
assert_equal(dW_dp, jac_solution2d)
示例8: test_affine_jacobian_3d_with_positions
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_affine_jacobian_3d_with_positions():
params = np.ones(12)
t = Affine.identity(3).from_vector(params)
explicit_pixel_locations = np.array(
[[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[0, 1, 1],
[0, 2, 0],
[0, 2, 1],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0],
[1, 1, 1],
[1, 2, 0],
[1, 2, 1]])
dW_dp = t.d_dp(explicit_pixel_locations)
assert_equal(dW_dp, jac_solution3d)
示例9: test_warp_to_mask_masked_image
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_warp_to_mask_masked_image():
mask = BooleanImage.blank((10, 10))
# make a funny mask on the original image
mask.pixels[2:, :] = False
img = MaskedImage.blank((10, 10), n_channels=2, mask=mask)
img.pixels[...] = 2.5
template_mask = BooleanImage.blank((10, 10), fill=False)
template_mask.pixels[:5, :5] = True
t = Affine.identity(2)
warped_img = img.warp_to_mask(template_mask, t)
assert(type(warped_img) == MaskedImage)
result = Image.blank((10, 10), n_channels=2).pixels
result[:5, :5, :] = 2.5
result_mask = BooleanImage.blank((10, 10), fill=False).pixels
result_mask[:2, :5] = True
assert(warped_img.n_true_pixels() == 10)
assert(np.all(result == warped_img.pixels))
assert(np.all(result_mask == warped_img.mask.pixels))
示例10: test_scipy_warp_multi
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_scipy_warp_multi():
target_transform = Affine.identity(2).from_vector(initial_params)
warped_im = rgb_image.warp_to(template_mask, target_transform)
assert(warped_im.shape == rgb_template.shape)
assert_allclose(warped_im.pixels, rgb_template.pixels)
示例11: test_affine_compose_inplace_affine
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_affine_compose_inplace_affine():
a = Affine.identity(2)
b = Affine.identity(2)
a.compose_before_inplace(b)
assert(np.all(a.h_matrix == b.h_matrix))
示例12: test_affine_identity_3d
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_affine_identity_3d():
assert_allclose(Affine.identity(3).h_matrix, np.eye(4))
示例13: test_affine_identity_2d
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def test_affine_identity_2d():
assert_allclose(Affine.identity(2).h_matrix, np.eye(3))
示例14: setup_conditions
# 需要导入模块: from menpo.transform import Affine [as 别名]
# 或者: from menpo.transform.Affine import identity [as 别名]
def setup_conditions(interpolator):
target_transform = Affine.identity(2).from_vector(target_params)
image_warped = image.warp_to(template_mask, target_transform,
interpolator=interpolator)
return image, image_warped, initial_params