NormalizeQuantile#
- class deeptrack.optical.math.NormalizeQuantile(quantiles: tuple[float, float] | Callable[[...], tuple[float, float]] = (0.25, 0.75), featurewise: bool | Callable[[...], bool] = True, channel_axis: int | None = -1, **kwargs: Any)#
Bases:
FeatureQuantile-based normalization.
Centers the input at the median and scales it using a quantile range:
output = (image - median) / (q_high - q_low)
Axis semantics: - If featurewise=False, quantiles are computed globally. - If featurewise=True and channel_axis is specified, quantiles are
computed independently per channel.
If featurewise=True and channel_axis=None, normalization falls back to global behavior.
The output preserves the input shape.
Parameters#
- quantiles: tuple[float, float]
Quantile range (q_min, q_max), with 0 < q_min < q_max < 1.
- featurewise: bool, optional
Whether to normalize per channel. Default is True.
- channel_axis: int or None, optional
Axis corresponding to channels. Default is -1.
Notes#
Not differentiable.
Examples#
>>> import deeptrack as dt
Create an input image.
>>> import numpy as np >>> >>> input_image = np.array([[10, 4], [4, -10]])
Define a quantile normalizer.
>>> normalizer = dt.NormalizeQuantile(quantiles=(0.25, 0.75)) >>> output_image = normalizer(input_image) >>> output_image array([[ 1.2, 0. ], [ 0. , -2.8]])
Methods Summary
get(image, quantiles, featurewise[, ...])Transform input data (abstract method).
Methods Documentation
- get(image: ndarray | Tensor, quantiles: tuple[float, float], featurewise: bool, channel_axis: int | None = -1, **kwargs: Any) ndarray | Tensor#
Transform input data (abstract method).
Abstract method that defines how the feature transforms the input data. The current values of all properties are passed as keyword arguments.
Parameters#
- data: Any
The input data to be transformed, most commonly a NumPy array or a PyTorch tensor, but it can be anything.
- _ID: tuple[int, …], optional
The unique identifier for the current execution. Defaults to ().
- **kwargs: Any
The current value of all properties in the properties attribute, as well as any global arguments passed to the feature.
Returns#
- Any
The transformed data.
Raises#
- NotImplementedError
Raised if this method is not overridden by subclasses.