Unsqueeze#

class deeptrack.features.Unsqueeze(axis: int | tuple[int, ...] | None = -1, **kwargs: dict[str, Any])#

Bases: Feature

Unsqueezes the input image to the smallest possible dimension.

This feature adds new singleton dimensions to the input image at the specified axis or axes. If no axis is specified, it defaults to adding a singleton dimension at the last axis.

Parameters#

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

The axis or axes where new singleton dimensions should be added. Defaults to None, which adds a singleton dimension at the last axis.

**kwargs:: dict of str to Any

Additional keyword arguments passed to the parent Feature class.

Methods#

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

Add singleton dimensions to the input image.

Examples#

>>> import deeptrack as dt
>>> import numpy as np

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

Apply an Unsqueeze feature: >>> unsqueeze_feature = dt.Unsqueeze(axis=0) >>> output_image = unsqueeze_feature(input_image) >>> print(output_image.shape) (1, 3)

Without specifying an axis: >>> unsqueeze_feature = dt.Unsqueeze() >>> output_image = unsqueeze_feature(input_image) >>> print(output_image.shape) (3, 1)

Methods Summary

get(image[, axis])

Add singleton dimensions to the input image.

Methods Documentation

get(image: np.ndarray, axis: int | tuple[int, ...] | None = -1, **kwargs: dict[str, Any]) np.ndarray#

Add singleton dimensions to the input image.

Parameters#

image: np.ndarray

The input image to process.

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

The axis or axes where new singleton dimensions should be added. Defaults to -1, which adds a singleton dimension at the last axis.

**kwargs:: dict of str to Any

Additional keyword arguments (unused here).

Returns#

np.ndarray

The input image with the specified singleton dimensions added.