AsType#

class deeptrack.features.AsType(dtype: Any | Callable[[...], Any] = 'float64', **kwargs: Dict[str, Any])#

Bases: Feature

Convert 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#

dtypePropertyLike[Any], optional

The desired data type for the image. Defaults to “float64”.

**kwargsDict[str, Any]

Additional keyword arguments passed to the parent Feature class.

Example#

>>> 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#

imagenp.ndarray

The input image to process.

dtypestr

The desired data type for the image.

**kwargsAny

Additional keyword arguments (unused here).

Returns#

np.ndarray

The input image converted to the specified data type.