if copy and not input_img_is_string:
img = _utils.copy_img(img)
return img
if target_affine is affine and target_shape is shape:
return img
if target_affine is not None:
target_affine = np.asarray(target_affine)
if (np.all(np.array(target_shape) == shape[:3]) and
np.allclose(target_affine, affine)):
if copy and not input_img_is_string:
img = _utils.copy_img(img)
return img
// We now know that some resampling must be done.
// The value of "copy" is of no importance: output is always a separate
// array.
data = img.get_data()
// Get a bounding box for the transformed data
// Embed target_affine in 4x4 shape if necessary
if target_affine.shape == (3, 3):
missing_offset = True
target_affine_tmp = np.eye(4)
target_affine_tmp[:3, :3] = target_affine
target_affine = target_affine_tmp
else:
missing_offset = False
target_affine = target_affine.copy()
print(affine)
print(target_affine)
transform_affine = np.linalg.inv(target_affine).dot(affine)
(xmin, xmax), (ymin, ymax), (zmin, zmax) = get_bounds(
data.shape[:3], transform_affine)