def make_isotropicBCC(
image,
interpolator=sitk.sitkLinear,
spacing=None,
default_value=0,
standardize_axes=False,):
original_spacing = image.GetSpacing()
# Make image isotropic via resampling.
original_size = image.GetSize()
if spacing is None:
spacing = min(original_spacing)
new_spacing = [spacing] * image.GetDimension()
new_size = [
int(round(osz * ospc / spacing))
for osz, ospc in zip(original_size, original_spacing)
]
new_direction = tuple((0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0))#image.GetDirection()
new_origin = image.GetOrigin()
# Only need to standardize axes if user requested and the original
# axes were not standard.
if standardize_axes and not np.array_equal(np.array(new_direction), np.identity(image.GetDimension()).ravel()):
new_direction = np.identity(image.GetDimension()).ravel()
# Compute bounding box for the original, non standard axes image.
boundary_points = []
for boundary_index in list(itertools.product(*zip([0, 0, 0], image.GetSize()))):
boundary_points.append(image.TransformIndexToPhysicalPoint(boundary_index))
max_coords = np.max(boundary_points, axis=0)
min_coords = np.min(boundary_points, axis=0)
new_origin = min_coords
new_size = (((max_coords - min_coords) / spacing).round().astype(int)).tolist()
return sitk.Resample(
image,
new_size,
sitk.Transform(),
interpolator,
new_origin,
new_spacing,
new_direction,
default_value,
image.GetPixelID(),
)
The above is my function I built using simpleITK, I am trying to understand what is code for sitk.Transform() in the above? I could not get a GitHub link to the code, because I want to understand how the transformation and resampling works for the above function.