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
04_create_patches_cancer_pred_anno.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录