baby.augmentation.ScalingAugmenter¶
- class baby.augmentation.ScalingAugmenter(*args, target_pixel_size=0.263, scale_frac=0.05, **kwargs)¶
Bases:
SmoothedLabelAugmenter
Augmenter with a target pixel size
Assumes that images have pixel_size property in their meta info. If it is missing, images are assumed to be at the target size.
NB: The downscale augmentation can now also upscale the image.
Methods
__call__
(img, lbl_info)This augmenter needs to be used in combination with a label preprocessing function that returns both images and info.
elastic_deform
(img, lbl[, params])Slight deformation
hflip
(img, lbl)Horizontal flip
hshift
(img, lbl[, maxpix])Shift along width, max of 10px by default
identity
(img, lbl)Do nothing
movestacks
(img, lbl)Translate stacks in img to increase robustness to shifts in focus
noise
(img, lbl)Add gaussian noise to the img (not the lbl)
rotate
(img, lbl)Random rotation
substacks
(img, lbl)Randomly pick Z-sections to match the chosen substack size
vflip
(img, lbl)Vertical flip
vshift
(img, lbl[, maxpix])Shift along height, max of 10px by default
crop
downscale
- __init__(*args, target_pixel_size=0.263, scale_frac=0.05, **kwargs)¶
Random data augmentation of img and lbl.
- Parameters
- xy_outint or pair of ints as a tuple
The intended width and height of the final augmented image.
- probsdict of floats in [0, 1]
Specify non-default probabilities for the named augmentations. Augmentations with zero probability are omitted.
- p_noopfloat in [0, 1]
Adjusts the probability for no augmentation operation in the default case. If set to 1, then all operations will be omitted by default (i.e., unless a non-zero probability is specified for that operation in probs).
Methods
__init__
(*args[, target_pixel_size, scale_frac])Random data augmentation of img and lbl.
crop
(img, lbl[, xysize])downscale
(img, lbl[, maxpix])elastic_deform
(img, lbl[, params])Slight deformation
hflip
(img, lbl)Horizontal flip
hshift
(img, lbl[, maxpix])Shift along width, max of 10px by default
identity
(img, lbl)Do nothing
movestacks
(img, lbl)Translate stacks in img to increase robustness to shifts in focus
noise
(img, lbl)Add gaussian noise to the img (not the lbl)
rotate
(img, lbl)Random rotation
substacks
(img, lbl)Randomly pick Z-sections to match the chosen substack size
vflip
(img, lbl)Vertical flip
vshift
(img, lbl[, maxpix])Shift along height, max of 10px by default
- elastic_deform(img, lbl, params={})¶
Slight deformation
Elastic deformation of images as described in Simard, Steinkraus and Platt, “Best Practices for Convolutional Neural Networks applied to Visual Document Analysis”, in Proc. of the International Conference on Document Analysis and Recognition, 2003. Adapted from: https://gist.github.com/chsasank/4d8f68caf01f041a6453e67fb30f8f5a
Example image:
- hflip(img, lbl)¶
Horizontal flip
Example image:
- hshift(img, lbl, maxpix=None)¶
Shift along width, max of 10px by default
Only integer shifts are made (i.e., no interpolation)
Example image:
- identity(img, lbl)¶
Do nothing
Example image:
- movestacks(img, lbl)¶
Translate stacks in img to increase robustness to shifts in focus
Only movements up or down by one stack are made, and the boundary is repeated
- noise(img, lbl)¶
Add gaussian noise to the img (not the lbl)
- rotate(img, lbl)¶
Random rotation
Example image:
- substacks(img, lbl)¶
Randomly pick Z-sections to match the chosen substack size
By default all Z-sections are used. If substacks was specified in the constructor, then Z-sections are randomly chosen to limit to that number of stacks. All subsets are considered except those where Z-sections are separated by more than one omitted Z-slice.
An error will be raised if the image has fewer Z-sections than the number specified in substacks.
Images presented to the augmenter call do not necessarily all need to have the same number of Z-sections; this will result in consistent output if substacks is specified, but will potentially result in inconsistent output in the default case.
- vflip(img, lbl)¶
Vertical flip
Example image:
- vshift(img, lbl, maxpix=None)¶
Shift along height, max of 10px by default
Only integer shifts are made (i.e., no interpolation)
Example image: