Density.rigid_transform#
- Density.rigid_transform(rotation_matrix, translation=None, order=3, use_geometric_center=True)[source]#
Performs a rigid transform of the class instance.
- Parameters:
- rotation_matrixNDArray
Rotation matrix to apply.
- translationNDArray
Translation to apply.
- orderint, optional
Interpolation order to use. Default is 3, has to be in range 0-5.
- use_geometric_centerbool, optional
Use geometric or mass center as rotation center.
- Returns:
- Density
The transformed instance of
Density
.
Notes
This function assumes the internal
Density.data
attribute is sufficiently sized to hold the transformation.Examples
Define the
Density
instance>>> import numpy as np >>> from tme import Density >>> dens = Density(np.arange(9).reshape(3,3).astype(np.float32)) >>> dens, translation = dens.centered(0)
and apply the rotation, in this case a mirror around the z-axis
>>> rotation_matrix = np.eye(dens.data.ndim) >>> rotation_matrix[0, 0] = -1 >>> dens_transform = dens.rigid_transform(rotation_matrix = rotation_matrix) >>> dens_transform.data array([[0. , 0. , 0. , 0. , 0. ], [0.5 , 3.0833333 , 3.5833333 , 3.3333333 , 0. ], [0.75 , 4.6666665 , 5.6666665 , 5.4166665 , 0. ], [0.25 , 1.6666666 , 2.6666667 , 2.9166667 , 0. ], [0. , 0.08333334, 0.5833333 , 0.8333333 , 0. ]], dtype=float32)