NormalizeStandard#

class deeptrack.optical.math.NormalizeStandard(featurewise: bool | Callable[[...], bool] = True, channel_axis: int | None = -1, **kwargs: Any)#

Bases: Feature

Standardize an array to zero mean and unit variance.

Applies z-score normalization:

output = (input - mean) / std

where the standard deviation is computed as the population standard deviation (dividing by N, not N-1).

Axis semantics: - If featurewise=False, normalization is applied globally. - If featurewise=True and channel_axis is specified, normalization is

applied independently per channel.

  • If featurewise=True and channel_axis=None, normalization defaults to global behavior.

The output always preserves the input shape.

Parameters#

featurewise: bool, optional

Whether to normalize each feature independently. It default to True, which is the only behavior currently implemented.

Returns#

np.ndarray or torch.Tensor

Standardized array with the same shape as input.

Methods#

get(image: array, **kwargs: Any) -> array

Standardizes the input image to mean 0 and std deviation 1.

Examples#

>>> import deeptrack as dt

Create an input image.

>>> import numpy as np
>>>
>>> input_image = np.array([[1, 2], [3, 4]], dtype=float)
>>> standardizer = dt.NormalizeStandard()
>>> output_image = standardizer(input_image)
>>> output_image
array([[-1.34164079, -0.4472136 ],
    [ 0.4472136 ,  1.34164079]])

Methods Summary

get(image, featurewise[, channel_axis])

Standardize the input image to zero mean and unit variance.

Methods Documentation

get(image: ndarray | Tensor, featurewise: bool, channel_axis: int | None = -1, **kwargs: Any) ndarray | Tensor#

Standardize the input image to zero mean and unit variance.

Applies z-score normalization:

(image - mean) / std

where std is the population standard deviation (i.e., computed with denominator N).

Axis semantics: - If featurewise=False, normalization is applied globally over all elements. - If featurewise=True and channel_axis is specified, normalization is applied independently along each channel. - If featurewise=True and channel_axis=None, normalization falls back to global behavior.

The output preserves the input shape.

Parameters#

image: np.ndarray or torch.Tensor

Input array to standardize. Must match the selected backend.

featurewise: bool

Whether to normalize each channel independently.

channel_axis: int or None, optional

Axis corresponding to channels/features. If None, no channel-wise normalization is performed.

**kwargs: Any

Additional keyword arguments (unused).

Returns#

np.ndarray or torch.Tensor

Standardized array with the same shape and backend as the input.