Average#
- class deeptrack.optical.math.Average(axis: int | Callable[[...], int] = 0, features: list[Feature] | None = None, **kwargs: Any)#
Bases:
FeatureAverage of input arrays.
Computes the mean of a list of arrays along the specified axis or axes. By default, averaging is performed along axis 0 (the batch dimension).
This operation is purely algebraic and does not interpret dimensions (e.g., spatial vs channel). All axes are treated uniformly and must be specified explicitly.
If features is provided, each feature is resolved first and the results are averaged.
Parameters#
- axis: int or tuple[int], optional
Axis or axes along which to compute the average. Defaults to 0.
- features: list[Feature] or None, optional
List of features to resolve and average. Defaults to None.
Attributes#
- __distributed__: bool = False
Determines whether .get(…) is applied to each element independently (True) or to the list as a whole (False).
Methods#
- get(images, axis, **kwargs) -> np.ndarray | torch.Tensor
Computes the average of the input images along the given axis.
Examples#
>>> import deeptrack as dt
Create two input images.
>>> import numpy as np >>> >>> input_image0 = np.ones((10, 30, 20)) * 2 >>> input_image1 = np.ones((10, 30, 20)) * 4
Define a pipeline with the average feature along the dimension 0.
>>> average = dt.Average(axis=0) >>> output_image = average([input_image0, input_image1]) >>> output_image (10, 30, 20)
Define a pipeline with the average feature along the dimension 1.
>>> average = dt.Average(axis=1) >>> output_image = average([input_image0, input_image1]) >>> output_image.shape (2, 30, 20)
Define a pipeline averaging each image.
>>> average = dt.Average(axis=(1, 2, 3)) >>> output_image = average([input_image0, input_image1]) >>> output_image.shape (2,)
Methods Summary
get(images, axis, **kwargs)Compute the average of input images along the specified axis(es).
Methods Documentation
- get(images: list[ndarray | Tensor], axis: int | tuple[int], **kwargs: Any) ndarray | Tensor#
Compute the average of input images along the specified axis(es).
This method computes the average of the input images along the specified axis(es).
Parameters#
- images: array
The input images to average.
- axis: int or tuple(int)
Axis or axes along which to average.
Returns#
- array
The average of the input images along the specified axis.