Skip to content

Releases: aleju/imgaug

0.4.0

06 Feb 06:18
Compare
Choose a tag to compare

Table of Contents

  1. Overview
  2. Example Images
  3. Mixed-Category Patches
  4. Added
  5. Changed
  6. Refactored
  7. Fixed

Overview

Release 0.4.0 focused mainly on adding new augmenters and improving
the internal augmentation "backend".

The following augmenters were added (see the overview docs for more details):

  • ChangeColorTemperature: Gives images a red, orange or blue touch.
  • New Brightness augmenters: WithBrightnessChannels,
    MultiplyAndAddToBrightness, MultiplyBrightness, AddToBrightness.
  • New Dropout augmenters: Dropout2d, TotalDropout.
  • RemoveSaturation: Decreases the saturation of colors. Effects are similar
    to Grayscale.
  • Cartoon: Applies a cartoon-style to images (classical / not-learned).
  • MeanShiftBlur: Blurs images using a mean-shift clustering method.
    (Note: Very slow.)
  • Jigsaw: Splits the image into rectangular cells and randomly switches
    some pairs of neighbouring cells. (Note: Does not support bounding boxes,
    polygons and line strings.)
  • WithPolarWarping: Transforms images to polar coordinate space and applies
    child augmenters there.
  • SaveDebugImageEveryNBatches: Generates and saves at every N-th batch a
    debug image visualizing all inputs within the batch. Useful to gauge
    strength and effects of augmentations and quickly spot errors in ground truth
    data (e.g. misaligned bounding boxes).
  • Cutout: Removes rectangular subregions of images. Has some similarity with
    CoarseDropout.
  • Rain and RainLayer: Adds rain-like effects to images.
  • RandAugment: Combination of multiple augmenters. Similar to the paper
    description. (Note: Can currently only augment images.)
  • Identity: Same as Noop. Does nothing.
  • UniformColorQuantizationToNBits: Quantizes each image array component down
    to N bits. Similar to UniformColorQuantization. Has the alias
    Posterize.
  • Solarize: Invert with threshold.
  • RemoveCBAsByOutOfImageFraction, ClipCBAsToImagePlanes: Augmenters to
    remove or clip coordinate-based augmentables, e.g. bounding boxes
  • More blend augmenters:
    • BlendAlphaMask: Uses batch-wise generated masks for alpha-blending.
    • BlendAlphaSomeColors: Alpha-blends only within image regions having
      specific randomly chosen colors.
    • BlendAlphaSegMapClassIds: Alpha-blends only within image regions having
      specific class ids in segmentation maps.
    • BlendAlphaBoundingBoxes: Alpha-blends only within image regions covered
      by bounding boxes having specific labels.
    • BlendAlphaHorizontalLinearGradient: Alpha-blends using horizontal
      linear gradients.
    • BlendAlphaVerticalLinearGradient: Analogous.
    • BlendAlphaRegularGrid: Places a regular grid on each image and
      samples one alpha value per grid cell. Can be used e.g. to achieve
      coarse dropout.
    • BlendAlphaCheckerboard: Places also a regular grid on each image,
      but neighbouring cells use alpha values that are inverse to each other.
  • Shortcuts for Affine: ScaleX, ScaleY, TranslateX, TranslateY,
    Rotate, ShearX, ShearY.
  • Several new crop and pad augmenters: CenterCropToFixedSize,
    CenterPadToFixedSize, CropToMultiplesOf, CenterCropToMultiplesOf,
    PadToMultiplesOf, CenterPadToMultiplesOf, CropToPowersOf,
    CenterCropToPowersOf, PadToPowersOf, CenterPadToPowersOf,
    CropToAspectRatio, CenterCropToAspectRatio, PadToAspectRatio,
    CenterPadToAspectRatio, PadToSquare, CenterPadToSquare,
    CropToSquare, CenterCropToSquare.
  • Wrappers around imagecorruptions package (verified to have identical
    outputs):
    GaussianNoise, ShotNoise, ImpulseNoise, SpeckleNoise,
    GaussianBlur, GlassBlur, DefocusBlur, MotionBlur, ZoomBlur,
    Fog, Frost, Snow, Spatter, Contrast, Brightness, Saturate,
    JpegCompression, Pixelate, ElasticTransform.
    The augmenters are accessible via iaa.imgcorruptlike.<AugmenterName>.
  • Wrappers around PIL functions (verified to have identical outputs):
    Solarize, Posterize, Equalize, Autocontrast, EnhanceColor,
    EnhanceContrast, EnhanceBrightness, EnhanceSharpness, FilterBlur,
    FilterSmooth, FilterSmoothMore, FilterEdgeEnhance,
    FilterEdgeEnhanceMore FilterFindEdges, FilterContour,
    FilterEmboss, FilterSharpen, FilterDetail, Affine.
    The augmenters are accessible via iaa.pillike.<AugmenterName>.

Aside from these new augmenters, the following major changes were made:

  • Bounding boxes and line strings have now native augmentation methods.
    Previously, they were converted to keypoints at the start of the
    augmentation, which meant that child augmenters were unable to use
    augmentation routines geared towards these two input types as they would
    merely see a bunch of keypoints.
  • Augmentation happens now batchwise. Previously it was done
    input type-wise. This change should improve performance for batches with
    different types of inputs by re-using computation results for multiple
    inputs. It also makes the library more flexible.
  • Improved the default parameters of augmenters. Most of them will now
    produce medium-strength augmentations when instantiated without and
    parameters. E.g. CoarseDropout() will now produce decent augmentations
    instead of doing nothing. When using default parameters,
    Fliplr() and Flipud() will always flip (p=100%).
    TotalDropout() will always drop everything (p=100%).
    Grayscale() and RemoveSaturation() will always fully grayscale/desaturate.
    Rot90() will always rotate once (clockwise). Invert() will always
    invert all components (p=100%).
  • Reworked the standard parameters shared by all augmenters.
    random_state was renamed to seed, e.g. Affine(..., seed=1)
    is now valid. The parameter deterministic is now deprecated.
  • Many methods were added to augmentables, e.g. BoundingBoxesOnImage
    now supports index-based access (bbs[0] instead
    of bbs.bounding_boxes[0]).
  • The bounding box drawing methods now also draw each BB's label.
  • All augmenters are now tested to be pickle-able without errors.
  • The library is now compatible with numpy 1.18 and python 3.8.
  • This release fixes two significant bugs in Affine that could lead
    to unaligned outputs. It also fixes significant bugs related to
    bounding box augmentation and various other issues. The update
    is recommended. There are now around 5000 unique tests.

Example Images

Brightness

Three new brightness-related augmenters are introduced. The example below
shows AddToBrightness. First image is the input, the others show
AddToBrightness(-100) to AddToBrightness(100).

Cartoon

A new cartoon style filter is introduced, shown below. Each row starts with
the input image.

ChangeColorTemperature

The color temperature of images can now be modified. The example below
shows ChangeColorTemperature(kelvin=1000) to
ChangeColorTemperature(kelvin=5000), with the first image being the input.

Cutout

Cutout is added to the library. The first row shows the hyperparameters that
were used in the corresponding paper. The second row shows two cutout
iterations per image, using intensity values, random RGB values and gaussian
noise to fill in the pixels. First image in each row is the input.

Dropout2d and TotalDropout

Two new dropout augmenters, Dropout2d and TotalDropout, are added.
The example below shows Dropout2d. First image is the input.

Jigsaw

A jigsaw puzzle augmenter is added. The first row below shows its effects
using a grid size of 5x5. The second row shows 10x10.
First image in each row is the input.

MeanShiftBlur

A mean shift-based blur augmenter is added. First image below shows the input,
followed by MeanShiftBlur(5.0) to MeanShiftBlur(40.0).

Posterize

The example below shows Posterize (aka UniformQuantizationToNBits)
with n_bits=8 to n_bits=1. First image is the input.

Solarize

The example below shows Solarize, which is the same as Invert with a
threshold. First image is the input.

Rain

The example below shows the new Rain augmenter. First image is the input.

RandAugment

This release adds an implementation of RandAugment the following example
shows RandAugment(n=2, m=20). First image is the input.
...

Read more

0.3.0

24 Sep 06:48
3374fd2
Compare
Choose a tag to compare

0.3.0 - Summary Of Changes

Improved Segmentation Map Augmentation (#302)

The segmentation map augmentation was previously previously a wrapper
around heatmap augmentation. This patch introduces independent methods
for segmentation map augmentation. This makes the augmentation of such
inputs faster and more memory efficient. The internal representation (int
instead of floats) also becomes more intuitive.

This improvement leads to some breaking changes. To adapt to the new
version, the following steps should be sufficient for most users:

  • Rename all calls of SegmentationMapOnImage to SegmentationMapsOnImage
    (Map -> Maps).
  • Rename all calls of SegmentationMapsOnImage.get_arr_int() to
    SegmentationMapsOnImage.get_arr().
  • Remove the argument nb_classes from all calls of SegmentationMapsOnImage.
  • Remove the argument background_threshold from all
    calls as it is no longer supported.
  • Remove the argument draw_foreground_mask from all calls of
    SegmentationMapsOnImage.draw_on_image() as it is no longer supported.
  • Ensure that the input array to SegmentationMapsOnImage is always an
    int-like (int, uint or bool). Float arrays are now deprecated.
  • Adapt all calls SegmentationMapsOnImage.draw() and
    SegmentationMapsOnImage.draw_on_image(), as both of these now return a
    list of drawn images instead of a single array. (For a segmentation map
    array of shape (H,W,C) they return C drawn images. In most cases C=1,
    so simply call draw()[0] or draw_on_image()[0].)
  • Ensure that if SegmentationMapsOnImage.arr is accessed anywhere, the
    respective code can handle the new int32 (H,W,#maps) array form.
    Previously, it was float32 and the channel-axis had the same size as the
    max class id (+1) that could appear in the map.
  • Ensure that calls of <augmenter>.augment() or <augmenter>() that
    provide segmentation maps as numpy arrays (i.e. bypassing
    SegmentationMapsOnImage) use the shape (N,H,W,#maps) as
    (N,H,W) is no longer supported.

New RNG System (#375, #408)

numpy 1.17 introduces a new API for random number generation. This patch
adapts imgaug to automatically use the new API if it is available and
fall back to the old one otherwise. To achieve that, the module
imgaug.random is introduced, containing the new standard random number
generator imgaug.random.RNG. You can create a new RNG using a seed value
via RNG(seed) and it will take care of the rest. It supports all sampling
functions that numpy.random.RandomState and numpy.random.Generator
support. This new random number generator is now supposed to be used
wherever previously numpy.random.RandomState would have been used.
(For most users, this shouldn't change anything. Integer seeds are
still supported. If you used RandomState anywhere, that is also still
supported.)

Breaking changes related to this patch:

  • imgaug now uses a different seed at each run of the library. Previously,
    a fixed seed was used for each run, leading to the same agumentations. That
    confused some users as it differed from numpy's behaviour.
    The new "dynamic" seed is derived from numpy's seed and hence seeding numpy
    will also lead to imgaug being seeded. (It is not recommended to rely on
    that behaviour as it might be changed in the future. Use
    imgaug.random.seed() to set a custom seed.)
  • The constants imgaug.SEED_MIN_VALUE and imgaug.SEED_MAX_VALUE were
    removed. They are now in imgaug.random.
  • The constant imgaug.CURRENT_RANDOM_STATE was removed.
    Use imgaug.random.get_global_rng() instead.

Other Changes Related to numpy 1.17 (#302)

numpy 1.17 uses a new implementation of clip(), which turns int64 values
into float64 values. As a result, it is no longer safe to use int64 in
many augmenters and other functions/methods and hence these inputs are now
rejected. This affects at least ReplaceElementwise and thereby Dropout,
CoarseDropout, Salt, Pepper, SaltAndPepper, CoarseSalt,
CoarsePepper and CoarseSaltAndPepper. See the ReadTheDocs documentation
page about dtype support for more details.

In relation to this change, parameters in imgaug.parameters that previously
returned int64 were modified to now return int32 instead. Analogously,
float64 results were changed to float32.

New Augmenters

The following new augmenters were added to the library:

Canny edge detection (#316):

  • imgaug.augmenters.edges.Canny. Performs canny edge detection and colorizes
    the resulting binary image in random ways.

Pooling (#317):

  • imgaug.augmenters.edges.AveragePooling. Performs average pooling using a
    given kernel size. Very similar to AverageBlur.
  • imgaug.augmenters.edges.MaxPooling. Performs maximum pooling using a
    given kernel size.
  • imgaug.augmenters.edges.MinPooling. Analogous.
  • imgaug.augmenters.edges.MedianPooling. Analogous.

Hue and Saturation (#210, #319):

  • imgaug.augmenters.color.WithHueAndSaturation. Apply child augmenters to
    images in HSV colorspace. Automatically accounts for the hue being in
    angular representation.
  • imgaug.augmenters.color.AddToHue. Adds a defined value to the hue of each
    pixel in input images.
  • imgaug.augmenters.color.AddToSaturation. Adds a defined value to the
    saturation of each pixel in input images.
  • imgaug.augmenters.color.MultiplyHueAndSaturation. Multiplies the hue and/or
    saturation of all pixels in input images.
  • imgaug.augmenters.color.MultiplyHue. Analogous, affects always only the hue.
  • imgaug.augmenters.color.MultiplySaturation. Analogous, affects always only
    the saturation.

Color Quantization (#347):

  • imgaug.augmenters.color.UniformColorQuantization. Uniformly splits all
    possible colors into N different ones, then finds for each pixel in an
    image among the N colors the most similar one and replaces that pixel's
    color with the quantized color.
  • imgaug.augmenters.color.KMeansColorQuantization. Groups all colors in an
    each into N different ones using k-Means clustering. Then replaces each
    pixel'S color, analogously to UniformColorQuantization.

Voronoi (#348):

  • imgaug.augmenters.segmentation.Voronoi. Queries a point sampler to
    generate a large number of (x,y) coordinates on an image. Each such
    coordinate becomes a voronoi cell. All pixels within the voronoi cell
    are replaced by their average color. (Similar to Superpixels, this
    augmenter also supports to only replace p% of all cells with their
    average color.)
  • imgaug.augmenters.segmentation.UniformVoronoi. Shortcut to call Voronoi
    with a uniform points sampler. That sampler places N points on an image
    using uniform distributions (i.e. they are randomly spread over the image.)
  • imgaug.augmenters.segmentation.RegularGridVoronoi. Shortcut to call
    Voronoi with a regular grid points sampler. That points sampler generates
    coordinate on a regular grid with H rows and W cols. Some of these points
    can be randomly dropped to generate a less regular pattern.
  • imgaug.augmenters.segmentation.RelativeRegularGridVoronoi. Same as
    RegularGridVoronoi, but instead of using absolute numbers for H and W,
    they are defined as relative amounts w.r.t. image shapes, leading to more
    rows/cols on larger images.

New Augmentation Functions

One of the long term goals of the library is to move as much augmentation
logic as possible out of Augmenter instances and into functions. This
patch therefore adds several new augmentation functions:

  • imgaug.min_pool(). #369
  • imgaug.median_pool(). #369
  • augmenters.segmentation.segment_voronoi(). #348
  • augmenters.flip.fliplr(). #385
  • augmenters.flip.flipud(). #385
  • augmenters.color.change_colorspace_(). #409
  • augmenters.color.change_colorspace_batch_(). #409
  • augmenters.arithmetic.add_scalar(). #411
  • augmenters.arithmetic.add_elementwise(). #411
  • augmenters.arithmetic.replace_elementwise_(). #411
  • augmenters.arithmetic.compress_jpg(). #411

Colorspace Changes (#409)

The color space naming within the library had become rather messy in the
past as there were many colorspace-related augmenters, with some of them
not using constants for colorspace names/IDs and others defining their own
ones. This patch introduces a unified colorspace naming system for which the
following constants were added:

  • imgaug.CSPACE_RGB
  • imgaug.CSPACE_BGR
  • imgaug.CSPACE_GRAY
  • imgaug.CSPACE_CIE
  • imgaug.CSPACE_YCrCb
  • imgaug.CSPACE_HSV
  • imgaug.CSPACE_HLS
  • imgaug.CSPACE_Lab
  • imgaug.CSPACE_Luv
  • imgaug.CSPACE_YUV
  • imgaug.CSPACE_ALL

All colorspace-related augmenters should now support these constants.

Additionally, support for rarely used colorspaces -- mainly CIE, YCrCb,
Luv and YUV -- was previously unverified or non-existent. These colorspaces
are now tested for the underlying transformation functions and should be
supported by most colorspace-related augmenters. (Some augmenters may still
define their own subset of actually sensible colorspaces and only accept
these.)

Setting limits on memory usage of background augmentation (#305, #417)

The methods imap_batches() and imap_batches_unordered() of
imgaug.multicore.Pool have now the new argument output_buffer_size.
The argument set the maximum number of batches that may be handled anywhere
in the augmentation pipeline at a given time (i.e. in the steps "loaded and
waiting", "in augmentation" or "augmented and waiting"). It denotes the
total number of batches over all processes. Setting this argument to
an integer value avoids situations where Pool eats up all the available
memory due to the data loading and augmentation running faster than the
training.

`A...

Read more

0.2.9

05 May 11:48
Compare
Choose a tag to compare

This update mainly covers the following topics:

  • Moved classes/methods related to augmentable data to their own modules.
  • Added polygon augmentation methods.
  • Added line strings and line string augmentation methods.
  • Added easier augmentation interface.

New 'augmentables' Modules

For the Polygon and Line String augmentation, new classes and methods had to be added. The previous file for that was imgaug/imgaug.py, which however was already fairly large. Therefore, all classes and methods related to augmentable data were split off and moved to imgaug/augmentables/<type>.py. The new modules and their main contents are:

  • imgaug.augmentables.batches: Contains Batch, UnnormalizedBatch.
  • imgaug.augmentables.utils: Contains utility functions.
  • imgaug.augmentables.bbs: Contains BoundingBox, BoundingBoxesOnImage.
  • imgaug.augmentables.kps: Contains Keypoint, KeypointsOnImage.
  • imgaug.augmentables.polys: Contains Polygon, PolygonsOnImage.
  • imgaug.augmentables.lines: Contains LineString, LineStringsOnImage.
  • imgaug.augmentables.heatmaps: Contains HeatmapsOnImage.
  • imgaug.augmentables.segmaps: Contains SegmentationMapOnImage.

Currently, all augmentable classes can still be created via imgaug.<type>, e.g. imgaug.BoundingBox still works.

Changes related to the new modules:

  • Moved Keypoint, KeypointsOnImage and imgaug.imgaug.compute_geometric_median to augmentables/kps.py.
  • Moved BoundingBox, BoundingBoxesOnImage to augmentables/bbs.py.
  • Moved Polygon, PolygonsOnImage and related classes/functions to augmentables/polys.py.
  • Moved HeatmapsOnImage to augmentables/heatmaps.py.
  • Moved SegmentationMapOnImage to augmentables/segmaps.py.
  • Moved Batch to augmentables/batches.py.
  • Added module imgaug.augmentables.utils.
    • Added function normalize_shape().
    • Added function project_coords().
  • Moved line interpolation functions _interpolate_points(), _interpolate_point_pair() and _interpolate_points_by_max_distance() to imgaug.augmentables.utils and made them public functions.
  • Refactored __init__() of PolygonsOnImage, BoundingBoxesOnImage, KeypointsOnImage to make use of imgaug.augmentables.utils.normalize_shape().
  • Refactored KeypointsOnImage.on() to use imgaug.augmentables.utils.normalize_shape().
  • Refactored Keypoint.project() to use imgaug.augmentables.utils.project_coords().

Polygon Augmentation

Polygons were already part of imgaug for quite a while, but couldn't be augmented yet. This version adds methods to perform such augmentations. It also makes some changes to the Polygon class, see the list of changes below.

Example for polygon augmentation:

import imgaug as ia
import imgaug.augmenters as iaa
from imgaug.augmentables.polys import Polygon, PolygonsOnImage

image = ia.quokka(size=0.2)
psoi = PolygonsOnImage([
    Polygon([(0, 0), (20, 0), (20, 20)])
], shape=image.shape)

image_aug, psoi_aug = iaa.Affine(rotate=45).augment(
    images=[image],
    polygons=[psoi]
)

See imgaug-doc/notebooks for a jupyter notebook with many more examples.

Changes related to polygon augmentation:

  • Added _ConcavePolygonRecoverer to imgaug.augmentables.polys.
  • Added PolygonsOnImage to imgaug.augmentables.polys.
  • Added polygon augmentation methods:
    • Added augment_polygons() to Augmenter.
    • Added _augment_polygons() to Augmenter.
    • Added _augment_polygons_as_keypoints() to Augmenter.
    • Added argument polygons to imgaug.augmentables.batches.Batch.
    • Added attributes polygons_aug and polygons_unaug to imgaug.augmentables.batches.Batch.
    • Added polygon handling to Augmenter.augment_batches().
  • Added property Polygon.height.
  • Added property Polygon.width.
  • Added method Polygon.to_keypoints().
  • Added optional drawing of corner points to Polygon.draw_on_image() and PolygonsOnImage.draw_on_image().
  • Added argument raise_if_too_far_away=True to Polygon.change_first_point_by_coords().
  • Added imgaug.quokka_polygons() function to generate example polygon data.
  • [rarely breaking] Polygon.draw_on_image(), PolygonsOnImage.draw_on_image()
    • Refactored to make partial use LineString methods.
    • Added arguments size and size_perimeter to control polygon line thickness.
    • Renamed arguments alpha_perimeter to alpha_line, color_perimeter to color_line to align with LineStrings.
    • Renamed arguments alpha_fill to alpha_face and color_fill to color_face.
  • [rarely breaking] Changed the output of Polygon.clip_out_of_image() from MultiPolygon to list of Polygon.
    This breaks for anybody who has already used Polygon.clip_out_of_image().
  • Changed Polygon.exterior_almost_equals() to accept lists of tuples as argument other_polygon.
  • Changed arguments color and alpha in Polygon.draw_on_image() and PolygonsOnImage.draw_on_image() to represent
    the general color and alpha of the polygon. The colors/alphas of the inner area, perimeter and points are derived from
    color and alpha (unless color_inner, color_perimeter or color_points are set (analogous for alpha)).
  • Refactored Polygon.project() to use LineString.project().
  • Refactored Polygon.shift() to use LineString.shift().
  • [rarely breaking] Polygon.exterior_almost_equals(), Polygon.almost_equals()
    • Refactored to make use of LineString.coords_almost_equals().
    • Renamed argument interpolate to points_per_edge.
    • Renamed argument other_polygon to other.
  • Renamed color_line to color_lines, alpha_line to alpha_lines in Polygon.draw_on_image() and PolygonsOnImage.draw_on_image().
  • Fixed Polygon.clip_out_of_image(image) not handling image being a tuple.
  • Fixed Polygon.is_out_of_image() falsely only checking the corner points of the polygon.

LineString Augmentation

This version adds Line String augmentation. Line Strings are simply lines made up of consecutive corner points that are connected by straight lines. Line strings have similarity with polygons, but do not have a filled inner area and are not closed (i.e. first and last coordinate differ).

Similar to other augmentables, line string are represented with the classes LineString(<iterable of xy-coords>) and LineStringsOnImage(<iterable of LineString>, <shape of image>). They are augmented e.g. via Augmenter.augment_line_strings(<iterable of LineStringsOnImage>) or Augmenter.augment(images=..., line_strings=...).

Example:

import imgaug as ia
import imgaug.augmenters as iaa
from imgaug.augmentables.lines import LineString, LineStringsOnImage

image = ia.quokka(size=0.2)
lsoi = LineStringsOnImage([
    LineString([(0, 0), (20, 0), (20, 20)])
], shape=image.shape)

image_aug, lsoi_aug = iaa.Affine(rotate=45).augment(
    images=[image],
    line_strings=[lsoi]
)

See imgaug-doc/notebooks for a jupyter notebook with many more examples.

Simplified Augmentation Interface

Augmentation of different data corresponding to the same image(s) has been a bit convoluted in the past, as each data type had to be augmented on its own. E.g. to augment an image and its bounding boxes, one had to first switch the augmenters to deterministic mode, then augment the images, then the bounding boxes. This version adds methods that perform these steps in one call. Specifically, Augmenter.augment(...) is used for that, which has the alias Augmenter.__call__(...). One argument can be used for each augmentable, e.g. bounding_boxes=<bounding box data>.
Example:

import imgaug as ia
import imgaug.augmenters as iaa
from imgaug.augmentables.kps import Keypoint, KeypointsOnImage

image = ia.quokka(size=0.2)
kpsoi = KeypointsOnImage([Keypoint(x=0, y=10), Keypoint(x=10, y=5)],
                         shape=image.shape)

image_aug, kpsoi_aug = iaa.Affine(rotate=(-45, 45)).augment(
    image=image,
    keypoints=kpsoi
)

This will automatically make sure that image and keypoints are rotated by corresponding amounts.

Normalization methods have been added to that class, which allow it to process many more different inputs than just variations of *OnImage.
Example:

import imgaug as ia
import imgaug.augmenters as iaa

image = ia.quokka(size=0.2)
kps = [(0, 10), (10, 5)]

image_aug, kps_aug = iaa.Affine(rotate=(-45, 45)).augment(
    image=image, keypoints=kps)

Examples for other inputs that are automatically handled by augment():

  • Integer arrays as segmentation maps.
  • Float arrays for heatmaps.
  • list([N,4] ndarray) for bounding boxes. (One list for images,
    then N bounding boxes in (x1,y1,x2,y2) form.)
  • list(list(list(tuple))) for line strings. (One list for images,
    one list for line strings on the image, one list for coordinates within
    the line string. Each tuple must contain two values for xy-coordinates.)
  • list(list(imgaug.augmentables.polys.Polygon)) for polygons.
    Note that this "skips" imgaug.augmentables.polys.PolygonsOnImage.

In python <3.6, augment() is limited to a maximum of two inputs/outputs and if two inputs/outputs are used, then one of them must be image data and such (augmented) image data will always be returned first,
independent of the argument's order. E.g. augment(line_strings=<data>, polygons=<data>) would be invalid due to not containing image data. augment(polygons=<data>, images=<data>) would still return the images first, even though they are the second argument.

In python >=3.6, augment() may be called with more than two arguments and will respect their order.
Example:

import numpy as n...
Read more