Affine#

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

Bases: Augmentation

Augmenter to apply affine transformations to images.

Affine transformations involve:

  • Translation

  • Scaling

  • Rotation

  • Shearing

Some transformations involve interpolations between several pixels of the input image to generate output pixel values. The parameter order deals with the method of interpolation used for this.

Parameters#

scalenumber or tuple of number or list of number or dict {“x”: number, “y”: number}

Scaling factor to use, where 1.0 denotes “no change” and 0.5 is zoomed out to 50 percent of the original size. If two values are provided (using tuple, list, or dict), the two first dimensions of the input are scaled individually.

translatenumber or tuple of number or list of number or dict {“x”: number, “y”: number}

Translation in pixels.

translate_pxnumber or tuple of number or list of number or dict {“x”: number, “y”: number}

DEPRECATED, use translate.

rotatenumber

Rotation in radians, i.e. Rotation happens around the center of the image.

shearnumber

Shear in radians. Values in the range (-pi/4, pi/4) are common

orderint

Interpolation order to use. Same meaning as in skimage:

  • 0: Nearest-neighbor

  • 1: Bi-linear (default)

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

  • 3: Bi-cubic

  • 4: Bi-quartic

  • 5: Bi-quintic

Methods Summary

get(image, scale, translate, rotate, shear, ...)

Transform an image [abstract method].

Methods Documentation

get(image, scale, translate, rotate, shear, **kwargs)#

Transform an image [abstract method].

Abstract method that defines how the feature transforms the input. The current value of all properties will be passed as keyword arguments.

Parameters#

image‘Image’ or List[‘Image’]

The Image or list of images to transform.

**kwargsDict[str, Any]

The current value of all properties in properties as well as any global arguments.

Returns#

‘Image’ or List[‘Image’]

The transformed image or list of images.

Raises#

NotImplementedError

Must be overridden by subclasses.