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#

axis: int or tuple[int, …], optional

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

**kwargs:: dict of str to Any

Additional keyword arguments passed to the parent Feature class.

Methods#

get(image: np.ndarray, axis: int | tuple[int, …], **kwargs: dict[str, Any]) -> np.ndarray

Squeeze the input image by removing singleton dimensions.

Examples#

>>> 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: np.ndarray, axis: int | tuple[int, ...] | None = None, **kwargs: dict[str, Any]) np.ndarray#

Squeeze the input image by removing singleton dimensions.

Parameters#

image: np.ndarray

The input image to process.

axis: int or tuple[int, …], optional

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

**kwargs:: dict of str to Any

Additional keyword arguments (unused here).

Returns#

np.ndarray

The squeezed image with reduced dimensions.