AsType#
- class deeptrack.features.AsType(dtype: str | Callable[[...], str] = 'float64', **kwargs: Any)#
Bases:
FeatureConvert the data type of arrays.
Astype changes the data type (dtype) of input arrays to a specified type. The accepted types are standard NumPy or PyTorch data types (e.g., “float64”, “int32”, “uint8”, “int8”, and “torch.float32”).
Parameters#
- dtype: PropertyLike[str], optional
The desired data type for the image. Defaults to “float64”.
- **kwargs: Any
Additional keyword arguments passed to the parent Feature class.
Methods#
- get(inputs, dtype, **kwargs) -> array
Convert the data type of the input image.
Examples#
>>> import deeptrack as dt
Create an input array:
>>> import numpy as np >>> >>> input_array = np.array([1.5, 2.5, 3.5])
Apply an AsType feature to convert to “int32”:
>>> astype_feature = dt.AsType(dtype="int32") >>> output_array = astype_feature.get(input_array, dtype="int32") >>> output_array array([1, 2, 3], dtype=int32)
Verify the data type:
>>> output_array.dtype dtype('int32')
Methods Summary
get(inputs, dtype, **kwargs)Convert the data type of the input image.
Methods Documentation
- get(inputs: ndarray | Tensor, dtype: str, **kwargs: Any) ndarray | Tensor#
Convert the data type of the input image.
Parameters#
- inputs: array
The input data to process. It can be a NumPy array, a PyTorch tensor, or an Image.
- dtype: str
The desired data type.
- **kwargs: Any
Additional keyword arguments (unused here).
Returns#
- array
The input data converted to the specified data type. It can be a NumPy array or a PyTorch tensor.