imgaug.augmenters.segmentation¶
Augmenters that apply changes to images based on segmentation methods.
List of augmenters:

class
imgaug.augmenters.segmentation.
DropoutPointsSampler
(other_points_sampler, p_drop)[source]¶ Bases:
imgaug.augmenters.segmentation.IPointsSampler
Remove a defined fraction of sampled points.
Parameters: other_points_sampler (IPointsSampler) – Another point sampler that is queried to generate a list of points. The dropout operation will be applied to that list.
p_drop (number or tuple of number or imgaug.parameters.StochasticParameter) – The probability that a coordinate will be removed from the list of all sampled coordinates. A value of
1.0
would mean that (on average)100
percent of all coordinates will be dropped, while0.0
denotes0
percent. Note that this sampler will always ensure that at least one coordinate is left after the dropout operation, i.e. even1.0
will only drop all except one coordinate. If a
float
, then that value will be used for all images.  If a
tuple
(a, b)
, then a valuep
will be sampled from the interval[a, b]
per image.  If a
StochasticParameter
, then this parameter will be used to determine per coordinate whether it should be kept (sampled value of>0.5
) or shouldn’t be kept (sampled value of<=0.5
). If you instead want to provide the probability as a stochastic parameter, you can usually doimgaug.parameters.Binomial(1p)
to convert parameter p to a 0/1 representation.
 If a
Examples
>>> import imgaug.augmenters as iaa >>> sampler = iaa.DropoutPointsSampler( >>> iaa.RegularGridPointsSampler(10, 20), >>> 0.2)
Create a point sampler that first generates points following a regular grid of
10
rows and20
columns, then randomly drops20
percent of these points.Methods
sample_points
(self, images, random_state)Generate coordinates of points on images. 
sample_points
(self, images, random_state)[source]¶ Generate coordinates of points on images.
Parameters:  images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
list
of arrays, each one of them is expected to have three dimensions. If this is an array, it must be fourdimensional and the first axis is expected to denote the image index. ForRGB
images the array would hence have to be of shape(N, H, W, 3)
.  random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState) – A random state to use for any probabilistic function required
during the point sampling.
See
RNG()
for details.
Returns: An
(N,2)
float32
array containing(x,y)
subpixel coordinates, all of which being within the intervals[0.0, width]
and[0.0, height]
.Return type: ndarray
 images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a

class
imgaug.augmenters.segmentation.
IPointsSampler
[source]¶ Bases:
object
Interface for all point samplers.
Point samplers return coordinate arrays of shape
Nx2
. These coordinates can be used in other augmenters, see e.g.Voronoi
.Methods
sample_points
(self, images, random_state)Generate coordinates of points on images. 
sample_points
(self, images, random_state)[source]¶ Generate coordinates of points on images.
Parameters:  images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
list
of arrays, each one of them is expected to have three dimensions. If this is an array, it must be fourdimensional and the first axis is expected to denote the image index. ForRGB
images the array would hence have to be of shape(N, H, W, 3)
.  random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState) – A random state to use for any probabilistic function required
during the point sampling.
See
RNG()
for details.
Returns: An
(N,2)
float32
array containing(x,y)
subpixel coordinates, all of which being within the intervals[0.0, width]
and[0.0, height]
.Return type: ndarray
 images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a


class
imgaug.augmenters.segmentation.
RegularGridPointsSampler
(n_rows, n_cols)[source]¶ Bases:
imgaug.augmenters.segmentation.IPointsSampler
Sampler that generates a regular grid of coordinates on an image.
‘Regular grid’ here means that on each axis all coordinates have the same distance from each other. Note that the distance may change between axis.
Parameters: n_rows (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) – Number of rows of coordinates to place on each image, i.e. the number of coordinates on the yaxis. Note that for each image, the sampled value is clipped to the interval
[1..H]
, whereH
is the image height. If a single
int
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the discrete interval[a..b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
n_cols (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) – Number of columns of coordinates to place on each image, i.e. the number of coordinates on the xaxis. Note that for each image, the sampled value is clipped to the interval
[1..W]
, whereW
is the image width. If a single
int
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the discrete interval[a..b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
Examples
>>> import imgaug.augmenters as iaa >>> sampler = iaa.RegularGridPointsSampler( >>> n_rows=(5, 20), >>> n_cols=50)
Create a point sampler that generates regular grids of points. These grids contain
r
points on the yaxis, wherer
is sampled uniformly from the discrete interval[5..20]
per image. On the xaxis, the grids always contain50
points.Methods
sample_points
(self, images, random_state)Generate coordinates of points on images. 
sample_points
(self, images, random_state)[source]¶ Generate coordinates of points on images.
Parameters:  images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
list
of arrays, each one of them is expected to have three dimensions. If this is an array, it must be fourdimensional and the first axis is expected to denote the image index. ForRGB
images the array would hence have to be of shape(N, H, W, 3)
.  random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState) – A random state to use for any probabilistic function required
during the point sampling.
See
RNG()
for details.
Returns: An
(N,2)
float32
array containing(x,y)
subpixel coordinates, all of which being within the intervals[0.0, width]
and[0.0, height]
.Return type: ndarray
 images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a

class
imgaug.augmenters.segmentation.
RegularGridVoronoi
(n_rows=(10, 30), n_cols=(10, 30), p_drop_points=(0.0, 0.5), p_replace=(0.5, 1.0), max_size=128, interpolation='linear', seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]¶ Bases:
imgaug.augmenters.segmentation.Voronoi
Sample Voronoi cells from regular grids and coloraverage them.
This augmenter is a shortcut for the combination of
Voronoi
,RegularGridPointsSampler
andDropoutPointsSampler
. Hence, it generates a regular grid withR
rows andC
columns of coordinates on each image. Then, it dropsp
percent of theR*C
coordinates to randomize the grid. Each image pixel then belongs to the voronoi cell with the closest coordinate.Supported dtypes:
See
Voronoi
.Parameters: n_rows (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) – Number of rows of coordinates to place on each image, i.e. the number of coordinates on the yaxis. Note that for each image, the sampled value is clipped to the interval
[1..H]
, whereH
is the image height. If a single
int
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the discrete interval[a..b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
n_cols (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) – Number of columns of coordinates to place on each image, i.e. the number of coordinates on the xaxis. Note that for each image, the sampled value is clipped to the interval
[1..W]
, whereW
is the image width. If a single
int
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the discrete interval[a..b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
p_drop_points (number or tuple of number or imgaug.parameters.StochasticParameter, optional) – The probability that a coordinate will be removed from the list of all sampled coordinates. A value of
1.0
would mean that (on average)100
percent of all coordinates will be dropped, while0.0
denotes0
percent. Note that this sampler will always ensure that at least one coordinate is left after the dropout operation, i.e. even1.0
will only drop all except one coordinate. If a
float
, then that value will be used for all images.  If a
tuple
(a, b)
, then a valuep
will be sampled from the interval[a, b]
per image.  If a
StochasticParameter
, then this parameter will be used to determine per coordinate whether it should be kept (sampled value of>0.5
) or shouldn’t be kept (sampled value of<=0.5
). If you instead want to provide the probability as a stochastic parameter, you can usually doimgaug.parameters.Binomial(1p)
to convert parameter p to a 0/1 representation.
 If a
p_replace (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Defines for any segment the probability that the pixels within that segment are replaced by their average color (otherwise, the pixels are not changed). Examples:
 A probability of
0.0
would mean, that the pixels in no segment are replaced by their average color (image is not changed at all).  A probability of
0.5
would mean, that around half of all segments are replaced by their average color.  A probability of
1.0
would mean, that all segments are replaced by their average color (resulting in a voronoi image).
Behaviour based on chosen datatypes for this parameter:
 If a
number
, then that number will always be used.  If
tuple
(a, b)
, then a random probability will be sampled from the interval[a, b]
per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, it is expected to return values between0.0
and1.0
and will be queried for each individual segment to determine whether it is supposed to be averaged (>0.5
) or not (<=0.5
). Recommended to be some form ofBinomial(...)
.
 A probability of
max_size (int or None, optional) – Maximum image size at which the augmentation is performed. If the width or height of an image exceeds this value, it will be downscaled before the augmentation so that the longest side matches max_size. This is done to speed up the process. The final output image has the same size as the input image. Note that in case p_replace is below
1.0
, the down/upscaling will affect the notreplaced pixels too. UseNone
to apply no down/upscaling.interpolation (int or str, optional) – Interpolation method to use during downscaling when max_size is exceeded. Valid methods are the same as in
imresize_single_image()
.seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See
__init__()
.name (None or str, optional) – See
__init__()
.random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.
deterministic (bool, optional) – Deprecated since 0.4.0. See method
to_deterministic()
for an alternative and for details about what the “deterministic mode” actually does.
Examples
>>> import imgaug.augmenters as iaa >>> aug = iaa.RegularGridVoronoi(10, 20)
Place a regular grid of
10x20
(height x width
) coordinates on each image. Randomly drop on average20
percent of these points to create a less regular pattern. Then use the remaining coordinates to group the image pixels into voronoi cells and average the colors within them. The process is performed at an image size not exceeding128
px on any side (default). If necessary, the downscaling is performed usinglinear
interpolation (default).>>> aug = iaa.RegularGridVoronoi( >>> (10, 30), 20, p_drop_points=0.0, p_replace=0.9, max_size=None)
Same as above, generates a grid with randomly
10
to30
rows, drops none of the generates points, replaces only90
percent of the voronoi cells with their average color (the pixels of the remaining10
percent are not changed) and performs the transformation at the original image size (max_size=None
).Methods
__call__
(self, \*args, \*\*kwargs)Alias for augment()
.augment
(self[, return_batch, hooks])Augment a batch. augment_batch
(self, batch[, hooks])Deprecated. augment_batch_
(self, batch[, parents, hooks])Augment a single batch inplace. augment_batches
(self, batches[, hooks, …])Augment multiple batches. augment_bounding_boxes
(self, …[, parents, …])Augment a batch of bounding boxes. augment_heatmaps
(self, heatmaps[, parents, …])Augment a batch of heatmaps. augment_image
(self, image[, hooks])Augment a single image. augment_images
(self, images[, parents, hooks])Augment a batch of images. augment_keypoints
(self, keypoints_on_images)Augment a batch of keypoints/landmarks. augment_line_strings
(self, …[, parents, hooks])Augment a batch of line strings. augment_polygons
(self, polygons_on_images[, …])Augment a batch of polygons. augment_segmentation_maps
(self, segmaps[, …])Augment a batch of segmentation maps. copy
(self)Create a shallow copy of this Augmenter instance. copy_random_state
(self, source[, recursive, …])Copy the RNGs from a source augmenter sequence. copy_random_state_
(self, source[, …])Copy the RNGs from a source augmenter sequence (inplace). deepcopy
(self)Create a deep copy of this Augmenter instance. draw_grid
(self, images, rows, cols)Augment images and draw the results as a single gridlike image. find_augmenters
(self, func[, parents, flat])Find augmenters that match a condition. find_augmenters_by_name
(self, name[, regex, …])Find augmenter(s) by name. find_augmenters_by_names
(self, names[, …])Find augmenter(s) by names. get_all_children
(self[, flat])Get all children of this augmenter as a list. get_children_lists
(self)Get a list of lists of children of this augmenter. get_parameters
(self)See get_parameters()
.localize_random_state
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. localize_random_state_
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. pool
(self[, processes, maxtasksperchild, seed])Create a pool used for multicore augmentation. remove_augmenters
(self, func[, copy, …])Remove this augmenter or children that match a condition. remove_augmenters_
(self, func[, parents])Remove inplace children of this augmenter that match a condition. remove_augmenters_inplace
(self, func[, parents])Deprecated. reseed
(self[, random_state, deterministic_too])Deprecated. seed_
(self[, entropy, deterministic_too])Seed this augmenter and all of its children. show_grid
(self, images, rows, cols)Augment images and plot the results as a single gridlike image. to_deterministic
(self[, n])Convert this augmenter from a stochastic to a deterministic one.

class
imgaug.augmenters.segmentation.
RelativeRegularGridPointsSampler
(n_rows_frac, n_cols_frac)[source]¶ Bases:
imgaug.augmenters.segmentation.IPointsSampler
Regular grid coordinate sampler; places more points on larger images.
This is similar to
RegularGridPointsSampler
, but the number of rows and columns is given as fractions of each image’s height and width. Hence, more coordinates are generated for larger images.Parameters: n_rows_frac (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Relative number of coordinates to place on the yaxis. For a value
y
and image heightH
the number of actually placed coordinates (i.e. computed rows) is given byint(round(y*H))
. Note that for each image, the number of coordinates is clipped to the interval[1,H]
, whereH
is the image height. If a single
number
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the interval[a, b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
n_cols_frac (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Relative number of coordinates to place on the xaxis. For a value
x
and image heightW
the number of actually placed coordinates (i.e. computed columns) is given byint(round(x*W))
. Note that for each image, the number of coordinates is clipped to the interval[1,W]
, whereW
is the image width. If a single
number
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the interval[a, b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
Examples
>>> import imgaug.augmenters as iaa >>> sampler = iaa.RelativeRegularGridPointsSampler( >>> n_rows_frac=(0.01, 0.1), >>> n_cols_frac=0.2)
Create a point sampler that generates regular grids of points. These grids contain
round(y*H)
points on the yaxis, wherey
is sampled uniformly from the interval[0.01, 0.1]
per image andH
is the image height. On the xaxis, the grids always contain0.2*W
points, whereW
is the image width.Methods
sample_points
(self, images, random_state)Generate coordinates of points on images. 
sample_points
(self, images, random_state)[source]¶ Generate coordinates of points on images.
Parameters:  images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
list
of arrays, each one of them is expected to have three dimensions. If this is an array, it must be fourdimensional and the first axis is expected to denote the image index. ForRGB
images the array would hence have to be of shape(N, H, W, 3)
.  random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState) – A random state to use for any probabilistic function required
during the point sampling.
See
RNG()
for details.
Returns: An
(N,2)
float32
array containing(x,y)
subpixel coordinates, all of which being within the intervals[0.0, width]
and[0.0, height]
.Return type: ndarray
 images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a

class
imgaug.augmenters.segmentation.
RelativeRegularGridVoronoi
(n_rows_frac=(0.05, 0.15), n_cols_frac=(0.05, 0.15), p_drop_points=(0.0, 0.5), p_replace=(0.5, 1.0), max_size=None, interpolation='linear', seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]¶ Bases:
imgaug.augmenters.segmentation.Voronoi
Sample Voronoi cells from imagedependent grids and coloraverage them.
This augmenter is a shortcut for the combination of
Voronoi
,RegularGridPointsSampler
andDropoutPointsSampler
. Hence, it generates a regular grid withR
rows andC
columns of coordinates on each image. Then, it dropsp
percent of theR*C
coordinates to randomize the grid. Each image pixel then belongs to the voronoi cell with the closest coordinate.Note
In contrast to the other voronoi augmenters, this one uses
None
as the default value for max_size, i.e. the color averaging is always performed at full resolution. This enables the augmenter to make use of the additional points on larger images. It does however slow down the augmentation process.Supported dtypes:
See
Voronoi
.Parameters: n_rows_frac (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Relative number of coordinates to place on the yaxis. For a value
y
and image heightH
the number of actually placed coordinates (i.e. computed rows) is given byint(round(y*H))
. Note that for each image, the number of coordinates is clipped to the interval[1,H]
, whereH
is the image height. If a single
number
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the interval[a, b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
n_cols_frac (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Relative number of coordinates to place on the xaxis. For a value
x
and image heightW
the number of actually placed coordinates (i.e. computed columns) is given byint(round(x*W))
. Note that for each image, the number of coordinates is clipped to the interval[1,W]
, whereW
is the image width. If a single
number
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the interval[a, b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
p_drop_points (number or tuple of number or imgaug.parameters.StochasticParameter, optional) – The probability that a coordinate will be removed from the list of all sampled coordinates. A value of
1.0
would mean that (on average)100
percent of all coordinates will be dropped, while0.0
denotes0
percent. Note that this sampler will always ensure that at least one coordinate is left after the dropout operation, i.e. even1.0
will only drop all except one coordinate. If a
float
, then that value will be used for all images.  If a
tuple
(a, b)
, then a valuep
will be sampled from the interval[a, b]
per image.  If a
StochasticParameter
, then this parameter will be used to determine per coordinate whether it should be kept (sampled value of>0.5
) or shouldn’t be kept (sampled value of<=0.5
). If you instead want to provide the probability as a stochastic parameter, you can usually doimgaug.parameters.Binomial(1p)
to convert parameter p to a 0/1 representation.
 If a
p_replace (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Defines for any segment the probability that the pixels within that segment are replaced by their average color (otherwise, the pixels are not changed). Examples:
 A probability of
0.0
would mean, that the pixels in no segment are replaced by their average color (image is not changed at all).  A probability of
0.5
would mean, that around half of all segments are replaced by their average color.  A probability of
1.0
would mean, that all segments are replaced by their average color (resulting in a voronoi image).
Behaviour based on chosen datatypes for this parameter:
 If a
number
, then thatnumber
will always be used.  If
tuple
(a, b)
, then a random probability will be sampled from the interval[a, b]
per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, it is expected to return values between0.0
and1.0
and will be queried for each individual segment to determine whether it is supposed to be averaged (>0.5
) or not (<=0.5
). Recommended to be some form ofBinomial(...)
.
 A probability of
max_size (int or None, optional) – Maximum image size at which the augmentation is performed. If the width or height of an image exceeds this value, it will be downscaled before the augmentation so that the longest side matches max_size. This is done to speed up the process. The final output image has the same size as the input image. Note that in case p_replace is below
1.0
, the down/upscaling will affect the notreplaced pixels too. UseNone
to apply no down/upscaling.interpolation (int or str, optional) – Interpolation method to use during downscaling when max_size is exceeded. Valid methods are the same as in
imresize_single_image()
.seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See
__init__()
.name (None or str, optional) – See
__init__()
.random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.
deterministic (bool, optional) – Deprecated since 0.4.0. See method
to_deterministic()
for an alternative and for details about what the “deterministic mode” actually does.
Examples
>>> import imgaug.augmenters as iaa >>> aug = iaa.RelativeRegularGridVoronoi(0.1, 0.25)
Place a regular grid of
R x C
coordinates on each image, whereR
is the number of rows and computed asR=0.1*H
withH
being the height of the input image.C
is the number of columns and analogously estimated from the image widthW
asC=0.25*W
. Larger images will lead to largerR
andC
values. On average,20
percent of these grid coordinates are randomly dropped to create a less regular pattern. Then, the remaining coordinates are used to group the image pixels into voronoi cells and the colors within them are averaged.>>> aug = iaa.RelativeRegularGridVoronoi( >>> (0.03, 0.1), 0.1, p_drop_points=0.0, p_replace=0.9, max_size=512)
Same as above, generates a grid with randomly
R=r*H
rows, wherer
is sampled uniformly from the interval[0.03, 0.1]
andC=0.1*W
rows. No points are dropped. The augmenter replaces only90
percent of the voronoi cells with their average color (the pixels of the remaining10
percent are not changed). Images larger than512
px are temporarily downscaled (before sampling the grid points) so that no side exceeds512
px. This improves performance, but degrades the quality of the resulting image.Methods
__call__
(self, \*args, \*\*kwargs)Alias for augment()
.augment
(self[, return_batch, hooks])Augment a batch. augment_batch
(self, batch[, hooks])Deprecated. augment_batch_
(self, batch[, parents, hooks])Augment a single batch inplace. augment_batches
(self, batches[, hooks, …])Augment multiple batches. augment_bounding_boxes
(self, …[, parents, …])Augment a batch of bounding boxes. augment_heatmaps
(self, heatmaps[, parents, …])Augment a batch of heatmaps. augment_image
(self, image[, hooks])Augment a single image. augment_images
(self, images[, parents, hooks])Augment a batch of images. augment_keypoints
(self, keypoints_on_images)Augment a batch of keypoints/landmarks. augment_line_strings
(self, …[, parents, hooks])Augment a batch of line strings. augment_polygons
(self, polygons_on_images[, …])Augment a batch of polygons. augment_segmentation_maps
(self, segmaps[, …])Augment a batch of segmentation maps. copy
(self)Create a shallow copy of this Augmenter instance. copy_random_state
(self, source[, recursive, …])Copy the RNGs from a source augmenter sequence. copy_random_state_
(self, source[, …])Copy the RNGs from a source augmenter sequence (inplace). deepcopy
(self)Create a deep copy of this Augmenter instance. draw_grid
(self, images, rows, cols)Augment images and draw the results as a single gridlike image. find_augmenters
(self, func[, parents, flat])Find augmenters that match a condition. find_augmenters_by_name
(self, name[, regex, …])Find augmenter(s) by name. find_augmenters_by_names
(self, names[, …])Find augmenter(s) by names. get_all_children
(self[, flat])Get all children of this augmenter as a list. get_children_lists
(self)Get a list of lists of children of this augmenter. get_parameters
(self)See get_parameters()
.localize_random_state
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. localize_random_state_
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. pool
(self[, processes, maxtasksperchild, seed])Create a pool used for multicore augmentation. remove_augmenters
(self, func[, copy, …])Remove this augmenter or children that match a condition. remove_augmenters_
(self, func[, parents])Remove inplace children of this augmenter that match a condition. remove_augmenters_inplace
(self, func[, parents])Deprecated. reseed
(self[, random_state, deterministic_too])Deprecated. seed_
(self[, entropy, deterministic_too])Seed this augmenter and all of its children. show_grid
(self, images, rows, cols)Augment images and plot the results as a single gridlike image. to_deterministic
(self[, n])Convert this augmenter from a stochastic to a deterministic one.

class
imgaug.augmenters.segmentation.
SubsamplingPointsSampler
(other_points_sampler, n_points_max)[source]¶ Bases:
imgaug.augmenters.segmentation.IPointsSampler
Ensure that the number of sampled points is below a maximum.
This point sampler will sample points from another sampler and then – in case more points were generated than an allowed maximum – will randomly pick n_points_max of these.
Parameters:  other_points_sampler (IPointsSampler) – Another point sampler that is queried to generate a
list
of points. The dropout operation will be applied to thatlist
.  n_points_max (int) – Maximum number of allowed points. If other_points_sampler generates more points than this maximum, a random subset of size n_points_max will be selected.
Examples
>>> import imgaug.augmenters as iaa >>> sampler = iaa.SubsamplingPointsSampler( >>> iaa.RelativeRegularGridPointsSampler(0.1, 0.2), >>> 50 >>> )
Create a points sampler that places
y*H
points on the yaxis (withy
being0.1
andH
being an image’s height) andx*W
on the xaxis (analogous). Then, if that number of placed points exceeds50
(can easily happen for larger images), a random subset of50
points will be picked and returned.Methods
sample_points
(self, images, random_state)Generate coordinates of points on images. 
sample_points
(self, images, random_state)[source]¶ Generate coordinates of points on images.
Parameters:  images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
list
of arrays, each one of them is expected to have three dimensions. If this is an array, it must be fourdimensional and the first axis is expected to denote the image index. ForRGB
images the array would hence have to be of shape(N, H, W, 3)
.  random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState) – A random state to use for any probabilistic function required
during the point sampling.
See
RNG()
for details.
Returns: An
(N,2)
float32
array containing(x,y)
subpixel coordinates, all of which being within the intervals[0.0, width]
and[0.0, height]
.Return type: ndarray
 images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
 other_points_sampler (IPointsSampler) – Another point sampler that is queried to generate a

class
imgaug.augmenters.segmentation.
Superpixels
(p_replace=(0.5, 1.0), n_segments=(50, 120), max_size=128, interpolation='linear', seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]¶ Bases:
imgaug.augmenters.meta.Augmenter
Transform images parially/completely to their superpixel representation.
This implementation uses skimage’s version of the SLIC algorithm.
Note
This augmenter is fairly slow. See Performance.
Supported dtypes:
if (image size <= max_size):
uint8
: yes; fully testeduint16
: yes; testeduint32
: yes; testeduint64
: limited (1)int8
: yes; testedint16
: yes; testedint32
: yes; testedint64
: limited (1)float16
: no (2)float32
: no (2)float64
: no (3)float128
: no (2)bool
: yes; tested
 Superpixel mean intensity replacement requires computing
these means as
float64
s. This can cause inaccuracies for large integer values.
 Superpixel mean intensity replacement requires computing
these means as
 Error in scikitimage.
 Loss of resolution in scikitimage.
if (image size > max_size):
 minimum of (
imgaug.augmenters.segmentation.Superpixels(image size <= max_size)
,_ensure_image_max_size()
)
Parameters: p_replace (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Defines for any segment the probability that the pixels within that segment are replaced by their average color (otherwise, the pixels are not changed). Examples:
 A probability of
0.0
would mean, that the pixels in no segment are replaced by their average color (image is not changed at all).  A probability of
0.5
would mean, that around half of all segments are replaced by their average color.  A probability of
1.0
would mean, that all segments are replaced by their average color (resulting in a voronoi image).
Behaviour based on chosen datatypes for this parameter:
 If a
number
, then thatnumber
will always be used.  If
tuple
(a, b)
, then a random probability will be sampled from the interval[a, b]
per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, it is expected to return values between0.0
and1.0
and will be queried for each individual segment to determine whether it is supposed to be averaged (>0.5
) or not (<=0.5
). Recommended to be some form ofBinomial(...)
.
 A probability of
n_segments (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) – Rough target number of how many superpixels to generate (the algorithm may deviate from this number). Lower value will lead to coarser superpixels. Higher values are computationally more intensive and will hence lead to a slowdown.
 If a single
int
, then that value will always be used as the number of segments.  If a
tuple
(a, b)
, then a value from the discrete interval[a..b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
max_size (int or None, optional) – Maximum image size at which the augmentation is performed. If the width or height of an image exceeds this value, it will be downscaled before the augmentation so that the longest side matches max_size. This is done to speed up the process. The final output image has the same size as the input image. Note that in case p_replace is below
1.0
, the down/upscaling will affect the notreplaced pixels too. UseNone
to apply no down/upscaling.interpolation (int or str, optional) – Interpolation method to use during downscaling when max_size is exceeded. Valid methods are the same as in
imresize_single_image()
.seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See
__init__()
.name (None or str, optional) – See
__init__()
.random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.
deterministic (bool, optional) – Deprecated since 0.4.0. See method
to_deterministic()
for an alternative and for details about what the “deterministic mode” actually does.
Examples
>>> import imgaug.augmenters as iaa >>> aug = iaa.Superpixels(p_replace=1.0, n_segments=64)
Generate around
64
superpixels per image and replace all of them with their average color (standard superpixel image).>>> aug = iaa.Superpixels(p_replace=0.5, n_segments=64)
Generate around
64
superpixels per image and replace half of them with their average color, while the other half are left unchanged (i.e. they still show the input image’s content).>>> aug = iaa.Superpixels(p_replace=(0.25, 1.0), n_segments=(16, 128))
Generate between
16
and128
superpixels per image and replace25
to100
percent of them with their average color.Methods
__call__
(self, \*args, \*\*kwargs)Alias for augment()
.augment
(self[, return_batch, hooks])Augment a batch. augment_batch
(self, batch[, hooks])Deprecated. augment_batch_
(self, batch[, parents, hooks])Augment a single batch inplace. augment_batches
(self, batches[, hooks, …])Augment multiple batches. augment_bounding_boxes
(self, …[, parents, …])Augment a batch of bounding boxes. augment_heatmaps
(self, heatmaps[, parents, …])Augment a batch of heatmaps. augment_image
(self, image[, hooks])Augment a single image. augment_images
(self, images[, parents, hooks])Augment a batch of images. augment_keypoints
(self, keypoints_on_images)Augment a batch of keypoints/landmarks. augment_line_strings
(self, …[, parents, hooks])Augment a batch of line strings. augment_polygons
(self, polygons_on_images[, …])Augment a batch of polygons. augment_segmentation_maps
(self, segmaps[, …])Augment a batch of segmentation maps. copy
(self)Create a shallow copy of this Augmenter instance. copy_random_state
(self, source[, recursive, …])Copy the RNGs from a source augmenter sequence. copy_random_state_
(self, source[, …])Copy the RNGs from a source augmenter sequence (inplace). deepcopy
(self)Create a deep copy of this Augmenter instance. draw_grid
(self, images, rows, cols)Augment images and draw the results as a single gridlike image. find_augmenters
(self, func[, parents, flat])Find augmenters that match a condition. find_augmenters_by_name
(self, name[, regex, …])Find augmenter(s) by name. find_augmenters_by_names
(self, names[, …])Find augmenter(s) by names. get_all_children
(self[, flat])Get all children of this augmenter as a list. get_children_lists
(self)Get a list of lists of children of this augmenter. get_parameters
(self)See get_parameters()
.localize_random_state
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. localize_random_state_
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. pool
(self[, processes, maxtasksperchild, seed])Create a pool used for multicore augmentation. remove_augmenters
(self, func[, copy, …])Remove this augmenter or children that match a condition. remove_augmenters_
(self, func[, parents])Remove inplace children of this augmenter that match a condition. remove_augmenters_inplace
(self, func[, parents])Deprecated. reseed
(self[, random_state, deterministic_too])Deprecated. seed_
(self[, entropy, deterministic_too])Seed this augmenter and all of its children. show_grid
(self, images, rows, cols)Augment images and plot the results as a single gridlike image. to_deterministic
(self[, n])Convert this augmenter from a stochastic to a deterministic one. 
get_parameters
(self)[source]¶ See
get_parameters()
.

class
imgaug.augmenters.segmentation.
UniformPointsSampler
(n_points)[source]¶ Bases:
imgaug.augmenters.segmentation.IPointsSampler
Sample points uniformly on images.
This point sampler generates n_points points per image. The x and ycoordinates are both sampled from uniform distributions matching the respective image width and height.
Parameters: n_points (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) –
Number of points to sample on each image.
 If a single
int
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the discrete interval[a..b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
Examples
>>> import imgaug.augmenters as iaa >>> sampler = iaa.UniformPointsSampler(500)
Create a point sampler that generates an array of
500
random points for each input image. The x and ycoordinates of each point are sampled from uniform distributions.Methods
sample_points
(self, images, random_state)Generate coordinates of points on images. 
sample_points
(self, images, random_state)[source]¶ Generate coordinates of points on images.
Parameters:  images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
list
of arrays, each one of them is expected to have three dimensions. If this is an array, it must be fourdimensional and the first axis is expected to denote the image index. ForRGB
images the array would hence have to be of shape(N, H, W, 3)
.  random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState) – A random state to use for any probabilistic function required
during the point sampling.
See
RNG()
for details.
Returns: An
(N,2)
float32
array containing(x,y)
subpixel coordinates, all of which being within the intervals[0.0, width]
and[0.0, height]
.Return type: ndarray
 images (ndarray or list of ndarray) – One or more images for which to generate points.
If this is a
 If a single

class
imgaug.augmenters.segmentation.
UniformVoronoi
(n_points=(50, 500), p_replace=(0.5, 1.0), max_size=128, interpolation='linear', seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]¶ Bases:
imgaug.augmenters.segmentation.Voronoi
Uniformly sample Voronoi cells on images and average colors within them.
This augmenter is a shortcut for the combination of
Voronoi
withUniformPointsSampler
. Hence, it generates a fixed amount ofN
random coordinates of voronoi cells on each image. The cell coordinates are sampled uniformly using the image height and width as maxima.Supported dtypes:
See
Voronoi
.Parameters: n_points (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) –
Number of points to sample on each image.
 If a single
int
, then that value will always be used.  If a
tuple
(a, b)
, then a value from the discrete interval[a..b]
will be sampled per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, then that parameter will be queried to draw one value per image.
 If a single
p_replace (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Defines for any segment the probability that the pixels within that segment are replaced by their average color (otherwise, the pixels are not changed). Examples:
 A probability of
0.0
would mean, that the pixels in no segment are replaced by their average color (image is not changed at all).  A probability of
0.5
would mean, that around half of all segments are replaced by their average color.  A probability of
1.0
would mean, that all segments are replaced by their average color (resulting in a voronoi image).
Behaviour based on chosen datatypes for this parameter:
 If a
number
, then thatnumber
will always be used.  If
tuple
(a, b)
, then a random probability will be sampled from the interval[a, b]
per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, it is expected to return values between0.0
and1.0
and will be queried for each individual segment to determine whether it is supposed to be averaged (>0.5
) or not (<=0.5
). Recommended to be some form ofBinomial(...)
.
 A probability of
max_size (int or None, optional) – Maximum image size at which the augmentation is performed. If the width or height of an image exceeds this value, it will be downscaled before the augmentation so that the longest side matches max_size. This is done to speed up the process. The final output image has the same size as the input image. Note that in case p_replace is below
1.0
, the down/upscaling will affect the notreplaced pixels too. UseNone
to apply no down/upscaling.interpolation (int or str, optional) – Interpolation method to use during downscaling when max_size is exceeded. Valid methods are the same as in
imresize_single_image()
.seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See
__init__()
.name (None or str, optional) – See
__init__()
.random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.
deterministic (bool, optional) – Deprecated since 0.4.0. See method
to_deterministic()
for an alternative and for details about what the “deterministic mode” actually does.
Examples
>>> import imgaug.augmenters as iaa >>> aug = iaa.UniformVoronoi((100, 500))
Sample for each image uniformly the number of voronoi cells
N
from the interval[100, 500]
. Then generateN
coordinates by sampling uniformly the xcoordinates from[0, W]
and the ycoordinates from[0, H]
, whereH
is the image height andW
the image width. Then use these coordinates to group the image pixels into voronoi cells and average the colors within them. The process is performed at an image size not exceeding128
px on any side (default). If necessary, the downscaling is performed usinglinear
interpolation (default).>>> aug = iaa.UniformVoronoi(250, p_replace=0.9, max_size=None)
Same as above, but always samples
N=250
cells, replaces only90
percent of them with their average color (the pixels of the remaining10
percent are not changed) and performs the transformation at the original image size (max_size=None
).Methods
__call__
(self, \*args, \*\*kwargs)Alias for augment()
.augment
(self[, return_batch, hooks])Augment a batch. augment_batch
(self, batch[, hooks])Deprecated. augment_batch_
(self, batch[, parents, hooks])Augment a single batch inplace. augment_batches
(self, batches[, hooks, …])Augment multiple batches. augment_bounding_boxes
(self, …[, parents, …])Augment a batch of bounding boxes. augment_heatmaps
(self, heatmaps[, parents, …])Augment a batch of heatmaps. augment_image
(self, image[, hooks])Augment a single image. augment_images
(self, images[, parents, hooks])Augment a batch of images. augment_keypoints
(self, keypoints_on_images)Augment a batch of keypoints/landmarks. augment_line_strings
(self, …[, parents, hooks])Augment a batch of line strings. augment_polygons
(self, polygons_on_images[, …])Augment a batch of polygons. augment_segmentation_maps
(self, segmaps[, …])Augment a batch of segmentation maps. copy
(self)Create a shallow copy of this Augmenter instance. copy_random_state
(self, source[, recursive, …])Copy the RNGs from a source augmenter sequence. copy_random_state_
(self, source[, …])Copy the RNGs from a source augmenter sequence (inplace). deepcopy
(self)Create a deep copy of this Augmenter instance. draw_grid
(self, images, rows, cols)Augment images and draw the results as a single gridlike image. find_augmenters
(self, func[, parents, flat])Find augmenters that match a condition. find_augmenters_by_name
(self, name[, regex, …])Find augmenter(s) by name. find_augmenters_by_names
(self, names[, …])Find augmenter(s) by names. get_all_children
(self[, flat])Get all children of this augmenter as a list. get_children_lists
(self)Get a list of lists of children of this augmenter. get_parameters
(self)See get_parameters()
.localize_random_state
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. localize_random_state_
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. pool
(self[, processes, maxtasksperchild, seed])Create a pool used for multicore augmentation. remove_augmenters
(self, func[, copy, …])Remove this augmenter or children that match a condition. remove_augmenters_
(self, func[, parents])Remove inplace children of this augmenter that match a condition. remove_augmenters_inplace
(self, func[, parents])Deprecated. reseed
(self[, random_state, deterministic_too])Deprecated. seed_
(self[, entropy, deterministic_too])Seed this augmenter and all of its children. show_grid
(self, images, rows, cols)Augment images and plot the results as a single gridlike image. to_deterministic
(self[, n])Convert this augmenter from a stochastic to a deterministic one.

class
imgaug.augmenters.segmentation.
Voronoi
(points_sampler, p_replace=1.0, max_size=128, interpolation='linear', seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]¶ Bases:
imgaug.augmenters.meta.Augmenter
Average colors of an image within Voronoi cells.
This augmenter performs the following steps:
 Query points_sampler to sample random coordinates of cell centers. On the image.
 Estimate for each pixel to which voronoi cell (i.e. segment) it belongs. Each pixel belongs to the cell with the closest center coordinate (euclidean distance).
 Compute for each cell the average color of the pixels within it.
 Replace the pixels of p_replace percent of all cells by their
average color. Do not change the pixels of
(1  p_replace)
percent of all cells. (The percentages are average values over many images. Some images may get more/less cells replaced by their average color.)
This code is very loosely based on https://codegolf.stackexchange.com/questions/50299/drawanimageasavoronoimap/50345#50345
Supported dtypes:
if (image size <= max_size):
uint8
: yes; fully testeduint16
: no; not testeduint32
: no; not testeduint64
: no; not testedint8
: no; not testedint16
: no; not testedint32
: no; not testedint64
: no; not testedfloat16
: no; not testedfloat32
: no; not testedfloat64
: no; not testedfloat128
: no; not testedbool
: no; not tested
if (image size > max_size):
 minimum of (
imgaug.augmenters.segmentation.Voronoi(image size <= max_size)
,_ensure_image_max_size()
)
Parameters: points_sampler (IPointsSampler) – A points sampler which will be queried per image to generate the coordinates of the centers of voronoi cells.
p_replace (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Defines for any segment the probability that the pixels within that segment are replaced by their average color (otherwise, the pixels are not changed). Examples:
 A probability of
0.0
would mean, that the pixels in no segment are replaced by their average color (image is not changed at all).  A probability of
0.5
would mean, that around half of all segments are replaced by their average color.  A probability of
1.0
would mean, that all segments are replaced by their average color (resulting in a voronoi image).
Behaviour based on chosen datatypes for this parameter:
 If a
number
, then thatnumber
will always be used.  If
tuple
(a, b)
, then a random probability will be sampled from the interval[a, b]
per image.  If a
list
, then a random value will be sampled from thatlist
per image.  If a
StochasticParameter
, it is expected to return values between0.0
and1.0
and will be queried for each individual segment to determine whether it is supposed to be averaged (>0.5
) or not (<=0.5
). Recommended to be some form ofBinomial(...)
.
 A probability of
max_size (int or None, optional) – Maximum image size at which the augmentation is performed. If the width or height of an image exceeds this value, it will be downscaled before the augmentation so that the longest side matches max_size. This is done to speed up the process. The final output image has the same size as the input image. Note that in case p_replace is below
1.0
, the down/upscaling will affect the notreplaced pixels too. UseNone
to apply no down/upscaling.interpolation (int or str, optional) – Interpolation method to use during downscaling when max_size is exceeded. Valid methods are the same as in
imresize_single_image()
.seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See
__init__()
.name (None or str, optional) – See
__init__()
.random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.
deterministic (bool, optional) – Deprecated since 0.4.0. See method
to_deterministic()
for an alternative and for details about what the “deterministic mode” actually does.
Examples
>>> import imgaug.augmenters as iaa >>> points_sampler = iaa.RegularGridPointsSampler(n_cols=20, n_rows=40) >>> aug = iaa.Voronoi(points_sampler)
Create an augmenter that places a
20x40
(HxW
) grid of cells on the image and replaces all pixels within each cell by the cell’s average color. The process is performed at an image size not exceeding128
px on any side (default). If necessary, the downscaling is performed usinglinear
interpolation (default).>>> points_sampler = iaa.DropoutPointsSampler( >>> iaa.RelativeRegularGridPointsSampler( >>> n_cols_frac=(0.05, 0.2), >>> n_rows_frac=0.1), >>> 0.2) >>> aug = iaa.Voronoi(points_sampler, p_replace=0.9, max_size=None)
Create a voronoi augmenter that generates a grid of cells dynamically adapted to the image size. Larger images get more cells. On the xaxis, the distance between two cells is
w * W
pixels, whereW
is the width of the image andw
is always0.1
. On the yaxis, the distance between two cells ish * H
pixels, whereH
is the height of the image andh
is sampled uniformly from the interval[0.05, 0.2]
. To make the voronoi pattern less regular, about20
percent of the cell coordinates are randomly dropped (i.e. the remaining cells grow in size). In contrast to the first example, the image is not resized (if it was, the sampling would happen after the resizing, which would affectW
andH
). Not all voronoi cells are replaced by their average color, only around90
percent of them. The remaining10
percent’s pixels remain unchanged.Methods
__call__
(self, \*args, \*\*kwargs)Alias for augment()
.augment
(self[, return_batch, hooks])Augment a batch. augment_batch
(self, batch[, hooks])Deprecated. augment_batch_
(self, batch[, parents, hooks])Augment a single batch inplace. augment_batches
(self, batches[, hooks, …])Augment multiple batches. augment_bounding_boxes
(self, …[, parents, …])Augment a batch of bounding boxes. augment_heatmaps
(self, heatmaps[, parents, …])Augment a batch of heatmaps. augment_image
(self, image[, hooks])Augment a single image. augment_images
(self, images[, parents, hooks])Augment a batch of images. augment_keypoints
(self, keypoints_on_images)Augment a batch of keypoints/landmarks. augment_line_strings
(self, …[, parents, hooks])Augment a batch of line strings. augment_polygons
(self, polygons_on_images[, …])Augment a batch of polygons. augment_segmentation_maps
(self, segmaps[, …])Augment a batch of segmentation maps. copy
(self)Create a shallow copy of this Augmenter instance. copy_random_state
(self, source[, recursive, …])Copy the RNGs from a source augmenter sequence. copy_random_state_
(self, source[, …])Copy the RNGs from a source augmenter sequence (inplace). deepcopy
(self)Create a deep copy of this Augmenter instance. draw_grid
(self, images, rows, cols)Augment images and draw the results as a single gridlike image. find_augmenters
(self, func[, parents, flat])Find augmenters that match a condition. find_augmenters_by_name
(self, name[, regex, …])Find augmenter(s) by name. find_augmenters_by_names
(self, names[, …])Find augmenter(s) by names. get_all_children
(self[, flat])Get all children of this augmenter as a list. get_children_lists
(self)Get a list of lists of children of this augmenter. get_parameters
(self)See get_parameters()
.localize_random_state
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. localize_random_state_
(self[, recursive])Assign augmenterspecific RNGs to this augmenter and its children. pool
(self[, processes, maxtasksperchild, seed])Create a pool used for multicore augmentation. remove_augmenters
(self, func[, copy, …])Remove this augmenter or children that match a condition. remove_augmenters_
(self, func[, parents])Remove inplace children of this augmenter that match a condition. remove_augmenters_inplace
(self, func[, parents])Deprecated. reseed
(self[, random_state, deterministic_too])Deprecated. seed_
(self[, entropy, deterministic_too])Seed this augmenter and all of its children. show_grid
(self, images, rows, cols)Augment images and plot the results as a single gridlike image. to_deterministic
(self[, n])Convert this augmenter from a stochastic to a deterministic one. 
get_parameters
(self)[source]¶ See
get_parameters()
.

imgaug.augmenters.segmentation.
segment_voronoi
(image, cell_coordinates, replace_mask=None)[source]¶ Average colors within voronoi cells of an image.
Parameters:  image (ndarray) – The image to convert to a voronoi image. May be
HxW
orHxWxC
. Note that forRGBA
images the alpha channel will currently also by averaged.  cell_coordinates (ndarray) – A
Nx2
float array containing the center coordinates of voronoi cells on the image. Values are expected to be in the interval[0.0, height1.0]
for the yaxis (xaxis analogous). If this array contains no coordinate, the image will not be changed.  replace_mask (None or ndarray, optional) – Boolean mask of the same length as cell_coordinates, denoting
for each cell whether its pixels are supposed to be replaced
by the cell’s average color (
True
) or left untouched (False
). If this is set toNone
, all cells will be replaced.
Returns: Voronoi image.
Return type: ndarray
 image (ndarray) – The image to convert to a voronoi image. May be