Affine#

class deeptrack.optical.augmentations.Affine(scale: float | tuple[float, float] | Callable[[...], float | tuple[float, float]] = 1, translate: float | tuple[float, float] | None | Callable[[...], float | tuple[float, float] | None] = None, translate_px: float | Callable[[...], float] = 0.0, rotate: float | Callable[[...], float] = 0.0, shear: float | Callable[[...], float] = 0.0, order: int | Callable[[...], int] = 1, cval: float | Callable[[...], float] = 0.0, mode: str | Callable[[...], str] = 'reflect', **kwargs)#

Bases: Augmentation

Apply affine transformations to images.

This augmentation performs geometric transformations including: - translation - scaling - rotation - shearing

Some transformations require interpolating between neighboring pixels to compute new output values. The order parameter controls the interpolation method.

Parameters#

scale: PropertyLike[float | tuple[float, float]]

Scaling factor. A value of 1.0 corresponds to no scaling. If two values are provided, the height and width are scaled independently.

translate: PropertyLike[float | tuple[float, float]] | None

Translation in pixels along the height and width axes.

translate_px: PropertyLike[float], optional

Legacy alias for translate. Used when translate is not provided. Defaults to 0.

rotate: PropertyLike[float], optional

Rotation angle in radians around the image center. Defaults to 0.

shear: PropertyLike[float], optional

Shear angle in radians. Defaults to 0.

order: PropertyLike[int], optional
Interpolation order used when resampling the image.
  • 0: Nearest-neighbor

  • 1: Bi-linear (default)

  • 2: Bi-quadratic (not recommended by skimage)

  • 3: Bi-cubic

  • 4: Bi-quartic

  • 5: Bi-quintic

cval: PropertyLike[float], optional

Constant value used to fill pixels when mode=”constant”. Defaults to 0.

mode: PropertyLike[str], optional

Boundary mode used when sampling outside the image domain. Options match scipy.ndimage.affine_transform. Defaults to “reflect”.

Methods#

get_numpy(image, **kwargs) -> np.ndarray

Applies the affine transformation to a NumPy array.

get_torch(image, **kwargs) -> torch.Tensor

Applies the affine transformation to a PyTorch tensor.

update_properties(…) -> ScatteredVolume | ScatteredField

Updates the properties of a ScatteredVolume or ScatteredField.