Unsqueeze#
- class deeptrack.features.Unsqueeze(axis: int | Tuple[int, ...] | None = -1, **kwargs: Dict[str, Any])#
Bases:
Feature
Unsqueezes the input image to the smallest possible dimension.
This feature adds new singleton dimensions to the input image at the specified axis or axes. If no axis is specified, it defaults to adding a singleton dimension at the last axis.
Parameters#
- axisint or Tuple[int, …], optional
The axis or axes where new singleton dimensions should be added. Defaults to None, which adds a singleton dimension at the last axis.
- **kwargsDict[str, Any]
Additional keyword arguments passed to the parent Feature class.
Example#
>>> import numpy as np >>> from deeptrack.features import Unsqueeze
Create an input array:
>>> input_image = np.array([1, 2, 3]) >>> print(input_image.shape) (3,)
Apply an Unsqueeze feature:
>>> unsqueeze_feature = Unsqueeze(axis=0) >>> output_image = unsqueeze_feature(input_image) >>> print(output_image.shape) (1, 3)
Without specifying an axis:
>>> unsqueeze_feature = Unsqueeze() >>> output_image = unsqueeze_feature(input_image) >>> print(output_image.shape) (3, 1)
Methods Summary
get
(image[, axis])Add singleton dimensions to the input image.
Methods Documentation
- get(image: ndarray, axis: int | Tuple[int, ...] | None = -1, **kwargs: Dict[str, Any]) ndarray #
Add singleton dimensions to the input image.
Parameters#
- imagenp.ndarray
The input image to process.
- axisint or Tuple[int, …], optional
The axis or axes where new singleton dimensions should be added. Defaults to -1, which adds a singleton dimension at the last axis.
- **kwargsDict[str, Any]
Additional keyword arguments (unused here).
Returns#
- np.ndarray
The input image with the specified singleton dimensions added.