MoveAxis#
- class deeptrack.features.MoveAxis(source: int, destination: int, **kwargs: Any)#
Bases:
FeatureMoves the axis of the input array or tensor.
This feature rearranges the axes of an input array or tensor, moving a specified source axis to a new destination position. All other axes remain in their original order.
Parameters#
- source: int
The source position of the axis to move.
- destination: int
The destination position of the axis.
- **kwargs: Any
Additional keyword arguments passed to the parent Feature class.
Methods#
- get(inputs, source, destination, **kwargs) -> array or tensor
Move the specified axis of the input to a new position. The input and output can be NumPy arrays or PyTorch tensors.
Examples#
>>> import deeptrack as dt
Create an input array:
>>> import numpy as np >>> >>> input_array = np.random.rand(2, 3, 4) >>> input_array.shape (2, 3, 4)
Apply a MoveAxis feature:
>>> move_axis_feature = dt.MoveAxis(source=0, destination=2) >>> output_array = move_axis_feature(input_array) >>> output_array.shape (3, 4, 2)
Methods Summary
get(inputs, source, destination, **kwargs)Move the specified axis of the input image to a new position.
Methods Documentation
- get(inputs: ndarray | Tensor, source: int, destination: int, **kwargs: Any) ndarray | Tensor#
Move the specified axis of the input image to a new position.
Parameters#
- inputs: array or tensor
The input image to process. The input can be a NumPy array or a PyTorch tensor.
- source: int
The axis to move.
- destination: int
The destination position of the axis.
- **kwargs: Any
Additional keyword arguments (unused here).
Returns#
- array or tensor
The input image with the specified axis moved to the destination. The output can be a NumPy array or a PyTorch tensor.