本文整理汇总了Python中scipy.ndimage.interpolation.affine_transform方法的典型用法代码示例。如果您正苦于以下问题:Python interpolation.affine_transform方法的具体用法?Python interpolation.affine_transform怎么用?Python interpolation.affine_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块scipy.ndimage.interpolation的用法示例。
在下文中一共展示了interpolation.affine_transform方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: random_rotation
点赞 6
# 需要导入模块: from scipy.ndimage import interpolation [as 别名]
# 或者: from scipy.ndimage.interpolation import affine_transform [as 别名]
def random_rotation(volume, rotation):
theta_x = np.pi / 180 * np.random.uniform(-rotation, rotation)
theta_y = np.pi / 180 * np.random.uniform(-rotation, rotation)
theta_z = np.pi / 180 * np.random.uniform(-rotation, rotation)
rotation_matrix_x = np.array([[1, 0, 0],
[0, np.cos(theta_x), -np.sin(theta_x)],
[0, np.sin(theta_x), np.cos(theta_x)]])
rotation_matrix_y = np.array([[np.cos(theta_y), 0, np.sin(theta_y)],
[0, 1, 0],
[-np.sin(theta_y), 0, np.cos(theta_y)]])
rotation_matrix_z = np.array([[np.cos(theta_z), -np.sin(theta_z), 0],
[np.sin(theta_z), np.cos(theta_z), 0],
[0, 0, 1]])
transform_matrix = np.dot(np.dot(rotation_matrix_x, rotation_matrix_y), rotation_matrix_z)
volume_rotated = affine_transform(volume, transform_matrix, mode='nearest')
return volume_rotated
开发者ID:mdai,项目名称:kaggle-lung-cancer,代码行数:18,
示例2: transform
点赞 6
# 需要导入模块: from scipy.ndimage import interpolation [as 别名]
# 或者: from scipy.ndimage.interpolation import affine_transform [as 别名]
def transform(self, translation, theta, method='opencv'):
"""Create a new image by translating and rotating the current image.
Parameters
----------
translation : :obj:`numpy.ndarray` of float
The XY translation vector.
theta : float
Rotation angle in radians, with positive meaning counter-clockwise.
method : :obj:`str`
Method to use for image transformations (opencv or scipy)
Returns
-------
:obj:`Image`
A