Squeeze#

class deeptrack.features.Squeeze(axis: int | Tuple[int, ...] | None = None, **kwargs: Dict[str, Any])#

Bases: Feature

Squeeze the input image to the smallest possible dimension.

This feature removes axes of size 1 from the input image. By default, it removes all singleton dimensions. If a specific axis or axes are specified, only those axes are squeezed.

Parameters#

axisint or Tuple[int, …], optional

The axis or axes to squeeze. Defaults to None, squeezing all axes.

**kwargsDict[str, Any]

Additional keyword arguments passed to the parent Feature class.

Example#

>>> import numpy as np
>>> from deeptrack.features import Squeeze

Create an input array with extra dimensions:

>>> input_image = np.array([[[[1], [2], [3]]]])
>>> print(input_image.shape)
(1, 1, 3, 1)

Create a Squeeze feature:

>>> squeeze_feature = Squeeze(axis=0)
>>> output_image = squeeze_feature(input_image)
>>> print(output_image.shape)
(1, 3, 1)

Without specifying an axis:

>>> squeeze_feature = Squeeze()
>>> output_image = squeeze_feature(input_image)
>>> print(output_image.shape)
(3,)

Methods Summary

get(image[, axis])

Squeeze the input image by removing singleton dimensions.

Methods Documentation

get(image: ndarray, axis: int | Tuple[int, ...] | None = None, **kwargs: Dict[str, Any]) ndarray#

Squeeze the input image by removing singleton dimensions.

Parameters#

imagenp.ndarray

The input image to process.

axisint or Tuple[int, …], optional

The axis or axes to squeeze. Defaults to None, which squeezes all axes.

**kwargsDict[str, Any]

Additional keyword arguments (unused here).

Returns#

np.ndarray

The squeezed image with reduced dimensions.