CropTight#
- class deeptrack.optical.augmentations.CropTight(eps: float | Callable[[...], float] = 1e-10, **kwargs: Any)#
Bases:
AugmentationCrop an array to remove empty space.
Removes leading and trailing indices along each axis where all values are below a threshold eps. This effectively crops the array to the smallest bounding box containing values larger than eps. Currently only supports 3D arrays of shape (H, W, Z).
Parameters#
- eps: PropertyLike[float], optional
Threshold below which values are considered empty. Defaults to 1e-10.
Methods#
- _get_numpy(image, **kwargs) -> np.ndarray
Applies tight cropping to a NumPy array.
- _get_torch(image, **kwargs) -> torch.Tensor
Applies tight cropping to a PyTorch tensor.
Examples#
>>> import deeptrack as dt >>> particle = dt.PointParticle(position=(32, 32)) >>> optics = dt.Fluorescence() >>> crop_tight = dt.CropTight(eps=1e-5) >>> image = optics(particle) >> crop_tight >>> image.plot()