AsType#
- class deeptrack.features.AsType(dtype: Any | Callable[[...], Any] = 'float64', **kwargs: dict[str, Any])#
Bases:
FeatureConvert the data type of images.
This feature changes the data type (dtype) of input images to a specified type. The accepted types are the same as those used by NumPy arrays, such as float64, int32, uint16, int16, uint8, and int8.
Parameters#
- dtype: PropertyLike[Any], optional
The desired data type for the image. Defaults to “float64”.
- **kwargs:: dict of str to Any
Additional keyword arguments passed to the parent Feature class.
Methods#
- get(image: np.ndarray, dtype: str, **kwargs: dict[str, Any]) -> np.ndarray
Convert the data type of the input image.
Examples#
>>> import numpy as np >>> from deeptrack.features import AsType
Create an input array: >>> input_image = np.array([1.5, 2.5, 3.5])
Apply an AsType feature to convert to int32: >>> astype_feature = AsType(dtype=”int32”) >>> output_image = astype_feature.get(input_image, dtype=”int32”) >>> print(output_image) [1 2 3]
Verify the data type: >>> print(output_image.dtype) int32
Methods Summary
get(image, dtype, **kwargs)Convert the data type of the input image.
Methods Documentation
- get(image: ndarray, dtype: str, **kwargs: dict[str, Any]) ndarray#
Convert the data type of the input image.
Parameters#
- image: np.ndarray
The input image to process.
- dtype: str
The desired data type for the image.
- **kwargs: Any
Additional keyword arguments (unused here).
Returns#
- np.ndarray
The input image converted to the specified data type.