deeptrack.augmentations Module#
Classes to augment images.
This module provides the augmentations DeepTrack2 classes that manipulates an image object with various transformations.
When used in a training pipeline, these augmentations synthetically increase the volume of training data for machine learning models.
Key Features#
General Augmentations
Basic image augmentation methods to perform transformations such as flipping an image horizontally (left-right), vertically (up-down), or along the diagonal.
Advanced Augmentations
For users who require more control over the image transformations. Advanced augmentation methods allow operations like translation, scaling, rotation, and shearing. These operations can be customized with user-specified parameters (e.g., degrees of rotation, scaling factors), giving flexibility in how the images are transformed.
Caching
To avoid redundant computations, the Reuse class offers caching functionality to save the outputs of feature outputs to be reused later, saving time and computational resources.
Cropping
Enables different methods to crop an image. Region-specific cropping, cropping based on multiples of height/width of and image, and crop to remove empty space at edges of an image.
Padding
Padding operations allow you to extend the shape of an image by adding extra pixels around its edges, which is essential for ensuring that the shape of the image stay consistent.
Module Structure#
Augmentation: Base class for augmentations.
Reuse: Stores and reuses feature outputs.
FlipLR: Flips image left to right.
FlipUD: Flips image up to down.
FlipDiagonal: Flips image along the diagonal.
Affine: Translation, scaling, rotation, shearing.
‘ElasticTransformation’: Transform using a displacement field.
Crop: Crop regions of an image.
CropToMultiplesOf: Crops image until height/width is multiple of a value.
CropTight: Crops to remove empty space at start and end of a 3D array.
Pad: Pads image with values.
PadMultiplesOf: Pad images until height/width is a multiple of a value.
Examples#
Flip an image of a particle up-down then flips left-right:
>>> import deeptrack as dt
>>> particle = dt.PointParticle()
>>> optics = dt.Fluorescence()
>>> image = dt.Value(optics(particle))\
... >> dt.FlipUD(p=1.0) >> dt.FlipLR(p=1.0)
image.plot()
Reuse the output of a pipeline twice, augmented randomly by FlipLR.
>>> import deeptrack as dt
>>> particle = dt.PointParticle()
>>> optics = dt.Fluorescence()
>>> pipeline = dt.Reuse(pipeline, uses=2) >> dt.FlipLR()
>>> image = optics(particle) >> pipeline
>>> image.plot()
Classes#
|
Augmenter to apply affine transformations to images. |
|
Base abstract augmentation class. |
|
Crops a regions of an image. |
|
Crops input array to remove empty space. |
|
Crop images down until their height/width is a multiple of a value. |
|
Transform images using displacement fields. |
|
Base feature class. |
|
Flips images along the main diagonal. |
|
Flips images left-right. |
|
Flips images up-down. |
|
Wrapper for array-like values with property tracking. |
|
Pads an image by adding extra pixels along specified axes. |
|
Pad images until their height/width is a multiple of a value. |
|
Acts like cache. |