NormalizeMinMax#

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

Bases: Feature

Min-max normalization of an array.

Applies a linear transformation that maps input values to the range [min, max].

If featurewise=False, normalization is applied globally over the entire input.

If featurewise=True, normalization is applied independently along channel_axis, which is interpreted as the feature/channel dimension.

Parameters#

min: float, optional

Lower bound of the output range. Default is 0.

max: float, optional

Upper bound of the output range. Default is 1.

featurewise: bool, optional

Whether to normalize each feature independently. Default is True.

channel_axis: int or None, optional

Axis corresponding to channels/features. If None, featurewise normalization is disabled even if featurewise=True. Default is -1.

Returns#

np.ndarray or torch.Tensor

Normalized array with the same shape as input.

Methods#

get(image, min, max, **kwargs) -> np.ndarray | torch.Tensor

Normalizes the image to be within the specified range.

Examples#

>>> import deeptrack as dt

Create an input image:

>>> import numpy as np
>>>
>>> input_image = np.array([[10, 4], [4, -10]])

Define a min-max normalizer:

>>> normalizer = dt.NormalizeMinMax(min=-5, max=5)
>>> output_image = normalizer(input_image)
>>> output_image
array([[ 5.,  2.],
       [ 2., -5.]])

Methods Summary

get(image, min, max[, featurewise, channel_axis])

Normalize the input to fall between min and max.

Methods Documentation

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

Normalize the input to fall between min and max.

Parameters#

image: np.ndarray or torch.Tensor

Input image to normalize.

min: float

Lower bound of the output range.

max: float

Upper bound of the output range.

featurewise: bool

Whether to normalize each feature (channel) independently.

channel_axis: int or None

Axis corresponding to channels/features. If None, normalization is always global.

Returns#

np.ndarray or torch.Tensor

Min-max normalized image.