Pool#
- class deeptrack.optical.math.Pool(ksize: int | tuple[int, int] | tuple[int, int, int] | Callable[[...], int | tuple[int, int] | tuple[int, int, int]] = 2, channel_axis: int | None = None, **kwargs: Any)#
Bases:
FeatureAbstract base class for pooling operations.
Pooling reduces the spatial resolution of an array by aggregating values over local neighborhoods defined by ksize.
The pooling window is specified as: - int → same size in all spatial dimensions - (px, py) → 2D pooling - (px, py, pz) → 3D pooling
If channel_axis is specified, pooling is applied independently per channel. Otherwise, all dimensions (including channels, if present) are treated as spatial.
Input dimensions are cropped (from the origin) to be divisible by the pooling size before applying pooling. Cropping is not centered: excess elements are removed from the right/bottom (or back).
Subclasses must implement _get_numpy and/or _get_torch, respect channel_axis and call _crop_to_multiple.
Parameters#
- ksize: int or tuple
Size of the pooling window.
- channel_axis: int or None, default=None
Axis corresponding to channels. Set to None to treat all dimensions as spatial.
Methods#
- get(image, ksize, channel_axis, **kwargs) –> array | tensor
Apply the pooling operation to the input image using the selected backend.
Methods Summary
get(image, **kwargs)Apply the pooling operation to the input image.
Methods Documentation
- get(image: np.ndarray | torch.Tensor | ScatteredVolume | ScatteredField, **kwargs: Any) np.ndarray | torch.Tensor#
Apply the pooling operation to the input image.
This method applies the pooling operation to the input image using the selected backend. It dispatches to the appropriate backend-specific implementation based on the type of the input image and the configured backend. It also handles unwrapping of scattered objects if necessary.
Parameters#
- image: np.ndarray or torch.Tensor or ScatteredVolume or ScatteredField
The input image to pool. Must be compatible with the selected backend. If a scattered object is provided, the pooling will be applied to its underlying array.
- **kwargs: Any
Additional keyword arguments.
Returns#
- np.ndarray or torch.Tensor or ScatteredVolume or ScatteredField
The pooled image, with reduced spatial resolution.