def _augment_polygons_as_keypoints(self, polygons_on_images, random_state,<EOL>parents, hooks, recoverer=None):

kps_ois = []<EOL>kp_counts = []<EOL>for polys_oi in polygons_on_images:<EOL><INDENT>kps = []<EOL>kp_counts_image = []<EOL>for poly in polys_oi.polygons:<EOL><INDENT>poly_kps = poly.to_keypoints()<EOL>kps.extend(poly_kps)<EOL>kp_counts_image.append(len(poly_kps))<EOL><DEDENT>kps_ois.append(ia.KeypointsOnImage(kps, shape=polys_oi.shape))<EOL>kp_counts.append(kp_counts_image)<EOL><DEDENT>kps_ois_aug = self._augment_keypoints(kps_ois, random_state, parents, hooks)<EOL>result = []<EOL>gen = enumerate(zip(kps_ois_aug, kp_counts))<EOL>for img_idx, (kps_oi_aug, kp_counts_image) in gen:<EOL><INDENT>polys_aug = []<EOL>counter = <NUM_LIT:0><EOL>for i, count in enumerate(kp_counts_image):<EOL><INDENT>poly_kps_aug = kps_oi_aug.keypoints[counter:counter+count]<EOL>poly_old = polygons_on_images[img_idx].polygons[i]<EOL>if recoverer is not None:<EOL><INDENT>poly_aug = recoverer.recover_from(<EOL>[(kp.x, kp.y) for kp in poly_kps_aug],<EOL>poly_old,<EOL>random_state=random_state)<EOL><DEDENT>else:<EOL><INDENT>poly_aug = poly_old.deepcopy(exterior=poly_kps_aug)<EOL><DEDENT>polys_aug.append(poly_aug)<EOL>counter += count<EOL><DEDENT>result.append(ia.PolygonsOnImage(polys_aug, shape=kps_oi_aug.shape))<EOL><DEDENT>return result<EOL>

Augment polygons by applying keypoint augmentation to their vertices.

Parameters
----------
polygons_on_images : list of imgaug.PolygonsOnImage
    Polygons to augment. They may be changed in-place.

random_state : numpy.random.RandomState
    The random state to use for all sampling tasks during the
    augmentation.

parents : list of imgaug.augmenters.meta.Augmenter
    See :func:`imgaug.augmenters.meta.Augmenter.augment_polygons`.

hooks : imgaug.HooksKeypoints or None
    See :func:`imgaug.augmenters.meta.Augmenter.augment_polygons`.

recoverer : None or imgaug._ConcavePolygonRecoverer
    An instance used to repair invalid polygons after augmentation.
    Must offer the method
    ``recover_from(new_exterior, old_polygon, random_state=0)``.
    If ``None`` then invalid polygons are not repaired.

Returns
----------
list of imgaug.PolygonsOnImage
    The augmented polygons.


def _augment_line_strings(self, line_strings_on_images, random_state,<EOL>parents, hooks):

<EOL>from imgaug.augmentables.lines import LineStringsOnImage<EOL>kps_ois = []<EOL>kp_counts = []<EOL>for ls_oi in line_strings_on_images:<EOL><INDENT>kps = []<EOL>kp_counts_image = []<EOL>for ls in ls_oi.line_strings:<EOL><INDENT>ls_kps = ls.to_keypoints()<EOL>kps.extend(ls_kps)<EOL>kp_counts_image.append(len(ls_kps))<EOL><DEDENT>kps_ois.append(ia.KeypointsOnImage(kps, shape=ls_oi.shape))<EOL>kp_counts.append(kp_counts_image)<EOL><DEDENT>kps_ois_aug = self._augment_keypoints(kps_ois, random_state, parents,<EOL>hooks)<EOL>result = []<EOL>gen = enumerate(zip(kps_ois_aug, kp_counts))<EOL>for img_idx, (kps_oi_aug, kp_counts_image) in gen:<EOL><INDENT>lss_aug = []<EOL>counter = <NUM_LIT:0><EOL>for i, count in enumerate(kp_counts_image):<EOL><INDENT>ls_kps_aug = kps_oi_aug.keypoints[counter:counter+count]<EOL>ls_old = line_strings_on_images[img_idx].line_strings[i]<EOL>ls_aug = ls_old.deepcopy(<EOL>coords=[(kp.x, kp.y) for kp in ls_kps_aug])<EOL>lss_aug.append(ls_aug)<EOL>counter += count<EOL><DEDENT>result.append(LineStringsOnImage(lss_aug, shape=kps_oi_aug.shape))<EOL><DEDENT>return result<EOL>

Augment line strings on images.

This is the internal version of ``augment_line_strings()``.
It is called from ``augment_line_strings()`` and should usually not be
called directly.
This method may transform the line strings in-place.
This method does not have to care about determinism or the
Augmenter instance's ``random_state`` variable. The parameter
``random_state`` takes care of both of these.

Parameters
----------
line_strings_on_images : list of imgaug.augmentables.lines.LineStringsOnImage
    Line strings to augment. They may be changed in-place.

random_state : numpy.random.RandomState
    The random state to use for all sampling tasks during the
    augmentation.

parents : list of imgaug.augmenters.meta.Augmenter
    See :func:`imgaug.augmenters.meta.Augmenter.augment_line_strings`.

hooks : imgaug.HooksKeypoints or None
    See :func:`imgaug.augmenters.meta.Augmenter.augment_line_strings`.

Returns
----------
list of imgaug.augmentables.lines.LineStringsOnImage
    The augmented line strings.


def augment(self, return_batch=False, hooks=None, **kwargs):

assert ia.is_single_bool(return_batch), (<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>") % (str(type(return_batch)),)<EOL>)<EOL>expected_keys = ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>"]<EOL>expected_keys_call = ["<STR_LIT:image>"] + expected_keys<EOL>assert any([key in kwargs for key in expected_keys_call]), (<EOL>"<STR_LIT>"<EOL>+ "<STR_LIT>" % (<EOL>"<STR_LIT:U+002CU+0020>".join(expected_keys_call),))<EOL>unknown_args = [key for key in kwargs.keys()<EOL>if key not in expected_keys_call]<EOL>assert len(unknown_args) == <NUM_LIT:0>, (<EOL>"<STR_LIT>" % (<EOL>"<STR_LIT:U+002CU+0020>".join(unknown_args)<EOL>))<EOL>if "<STR_LIT:image>" in kwargs:<EOL><INDENT>assert "<STR_LIT>" not in kwargs, (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>images = [kwargs["<STR_LIT:image>"]]<EOL><DEDENT>else:<EOL><INDENT>images = kwargs.get("<STR_LIT>", None)<EOL><DEDENT>order = "<STR_LIT>"<EOL>nb_keys = len(list(kwargs.keys()))<EOL>vinfo = sys.version_info<EOL>is_py36_or_newer = vinfo[<NUM_LIT:0>] > <NUM_LIT:3> or (vinfo[<NUM_LIT:0>] == <NUM_LIT:3> and vinfo[<NUM_LIT:1>] >= <NUM_LIT:6>)<EOL>if is_py36_or_newer:<EOL><INDENT>order = "<STR_LIT>"<EOL><DEDENT>elif not return_batch and nb_keys > <NUM_LIT:2>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>elif not return_batch and nb_keys == <NUM_LIT:2> and images is None:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>batch = UnnormalizedBatch(<EOL>images=images,<EOL>heatmaps=kwargs.get("<STR_LIT>", None),<EOL>segmentation_maps=kwargs.get("<STR_LIT>", None),<EOL>keypoints=kwargs.get("<STR_LIT>", None),<EOL>bounding_boxes=kwargs.get("<STR_LIT>", None),<EOL>polygons=kwargs.get("<STR_LIT>", None),<EOL>line_strings=kwargs.get("<STR_LIT>", None)<EOL>)<EOL>batch_aug = self.augment_batch(batch, hooks=hooks)<EOL>if return_batch:<EOL><INDENT>return batch_aug<EOL><DEDENT>result = []<EOL>if order == "<STR_LIT>":<EOL><INDENT>for key in kwargs:<EOL><INDENT>if key == "<STR_LIT:image>":<EOL><INDENT>attr = getattr(batch_aug, "<STR_LIT>")<EOL>result.append(attr[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>result.append(getattr(batch_aug, "<STR_LIT>" % (key,)))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for key in expected_keys:<EOL><INDENT>if key == "<STR_LIT>" and "<STR_LIT:image>" in kwargs:<EOL><INDENT>attr = getattr(batch_aug, "<STR_LIT>")<EOL>result.append(attr[<NUM_LIT:0>])<EOL><DEDENT>elif key in kwargs:<EOL><INDENT>result.append(getattr(batch_aug, "<STR_LIT>" % (key,)))<EOL><DEDENT><DEDENT><DEDENT>if len(result) == <NUM_LIT:1>:<EOL><INDENT>return result[<NUM_LIT:0>]<EOL><DEDENT>return tuple(result)<EOL>

Augment data.

This method is a wrapper around
``imgaug.augmentables.batches.UnnormalizedBatch`` and
``augment_batch()``. Hence, it supports the same datatypes as
``UnnormalizedBatch``.

If `return_batch` was not set to ``True``, the method will return
a tuple of augmentables. It will return the same types of augmentables
(only augmented) as input into the method. This behaviour
is partly specific to the python version:
  * In _python 3.6+_ (if ``return_batch=False``):
    * Three or more augmentables may be used as input.
    * The return order matches the order of the named arguments, e.g.
      ``B, D, C = augment(B=x, D=y, C=z)``.
    * None of the provided named arguments has to be `image` or `images`.
  * In _python <3.6_  (if ``return_batch=False``):
    * One or two augmentables may be used as input, not more than that.
    * At least one the augmentables has to be `image` or `images`.
    * The augmented images are always returned first.

If `return_batch` was not set to ``False``, an instance of
``UnnormalizedBatch`` will be returned. The output is the same for
all python version and any number or combination of augmentables may
be provided.

All augmentables must be provided as named arguments.
E.g. ``augment(<array>)`` will crash, but ``augment(images=<array>)``
will work.

Parameters
----------
image : None
    or (H,W,C) ndarray \
    or (H,W) ndarray, \
    optional
    The image to augment. Only this or `images` can be set, not both.
    If `return_batch` is ``False`` and the python version is below 3.6,
    either this or `images` _must_ be provided.

images : None \
    or (N,H,W,C) ndarray \
    or (N,H,W) ndarray \
    or iterable of (H,W,C) ndarray \
    or iterable of (H,W) ndarray, \
    optional
    The images to augment. Only this or `image` can be set, not both.
    If `return_batch` is ``False`` and the python version is below 3.6,
    either this or `image` _must_ be provided.

heatmaps : None \
    or (N,H,W,C) ndarray \
    or imgaug.augmentables.heatmaps.HeatmapsOnImage \
    or iterable of (H,W,C) ndarray \
    or iterable of imgaug.augmentables.heatmaps.HeatmapsOnImage, \
    optional
    The heatmaps to augment.
    If anything else than ``HeatmapsOnImage``, then the number of
    heatmaps must match the number of images provided via parameter
    `images`. The number is contained either in ``N`` or the first
    iterable's size.

segmentation_maps : None \
    or (N,H,W) ndarray \
    or imgaug.augmentables.segmaps.SegmentationMapOnImage \
    or iterable of (H,W) ndarray \
    or iterable of imgaug.augmentables.segmaps.SegmentationMapOnImage, \
    optional
    The segmentation maps to augment.
    If anything else than ``SegmentationMapOnImage``, then the number
    of segmaps must match the number of images provided via parameter
    `images`. The number is contained either in ``N`` or the first
    iterable's size.

keypoints : None \
    or list of (N,K,2) ndarray \
    or tuple of number \
    or imgaug.augmentables.kps.Keypoint \
    or iterable of (K,2) ndarray \
    or iterable of tuple of number \
    or iterable of imgaug.augmentables.kps.Keypoint \
    or iterable of imgaug.augmentables.kps.KeypointOnImage \
    or iterable of iterable of tuple of number \
    or iterable of iterable of imgaug.augmentables.kps.Keypoint, \
    optional
    The keypoints to augment.
    If a tuple (or iterable(s) of tuple), then iterpreted as (x,y)
    coordinates and must hence contain two numbers.
    A single tuple represents a single coordinate on one image, an
    iterable of tuples the coordinates on one image and an iterable of
    iterable of tuples the coordinates on several images. Analogous if
    ``Keypoint`` objects are used instead of tuples.
    If an ndarray, then ``N`` denotes the number of images and ``K``
    the number of keypoints on each image.
    If anything else than ``KeypointsOnImage`` is provided, then the
    number of keypoint groups must match the number of images provided
    via parameter `images`. The number is contained e.g. in ``N`` or
    in case of "iterable of iterable of tuples" in the first iterable's
    size.

bounding_boxes : None \
    or (N,B,4) ndarray \
    or tuple of number \
    or imgaug.augmentables.bbs.BoundingBox \
    or imgaug.augmentables.bbs.BoundingBoxesOnImage \
    or iterable of (B,4) ndarray \
    or iterable of tuple of number \
    or iterable of imgaug.augmentables.bbs.BoundingBox \
    or iterable of imgaug.augmentables.bbs.BoundingBoxesOnImage \
    or iterable of iterable of tuple of number \
    or iterable of iterable imgaug.augmentables.bbs.BoundingBox, \
    optional
    The bounding boxes to augment.
    This is analogous to the `keypoints` parameter. However, each
    tuple -- and also the last index in case of arrays -- has size 4,
    denoting the bounding box coordinates ``x1``, ``y1``, ``x2`` and
    ``y2``.

polygons : None  \
    or (N,#polys,#points,2) ndarray \
    or imgaug.augmentables.polys.Polygon \
    or imgaug.augmentables.polys.PolygonsOnImage \
    or iterable of (#polys,#points,2) ndarray \
    or iterable of tuple of number \
    or iterable of imgaug.augmentables.kps.Keypoint \
    or iterable of imgaug.augmentables.polys.Polygon \
    or iterable of imgaug.augmentables.polys.PolygonsOnImage \
    or iterable of iterable of (#points,2) ndarray \
    or iterable of iterable of tuple of number \
    or iterable of iterable of imgaug.augmentables.kps.Keypoint \
    or iterable of iterable of imgaug.augmentables.polys.Polygon \
    or iterable of iterable of iterable of tuple of number \
    or iterable of iterable of iterable of tuple of \
    imgaug.augmentables.kps.Keypoint, \
    optional
    The polygons to augment.
    This is similar to the `keypoints` parameter. However, each polygon
    may be made up of several (x,y) coordinates (three or more are
    required for valid polygons).
    The following datatypes will be interpreted as a single polygon on
    a single image:
      * ``imgaug.augmentables.polys.Polygon``
      * ``iterable of tuple of number``
      * ``iterable of imgaug.augmentables.kps.Keypoint``

    The following datatypes will be interpreted as multiple polygons
    on a single image:
      * ``imgaug.augmentables.polys.PolygonsOnImage``
      * ``iterable of imgaug.augmentables.polys.Polygon``
      * ``iterable of iterable of tuple of number``
      * ``iterable of iterable of imgaug.augmentables.kps.Keypoint``
      * ``iterable of iterable of imgaug.augmentables.polys.Polygon``

    The following datatypes will be interpreted as multiple polygons on
    multiple images:
      * ``(N,#polys,#points,2) ndarray``
      * ``iterable of (#polys,#points,2) ndarray``
      * ``iterable of iterable of (#points,2) ndarray``
      * ``iterable of iterable of iterable of tuple of number``
      * ``iterable of iterable of iterable of tuple of imgaug.augmentables.kps.Keypoint``

line_strings : None \
    or (N,#lines,#points,2) ndarray \
    or imgaug.augmentables.lines.LineString \
    or imgaug.augmentables.lines.LineStringOnImage \
    or iterable of (#polys,#points,2) ndarray \
    or iterable of tuple of number \
    or iterable of imgaug.augmentables.kps.Keypoint \
    or iterable of imgaug.augmentables.lines.LineString \
    or iterable of imgaug.augmentables.lines.LineStringOnImage \
    or iterable of iterable of (#points,2) ndarray \
    or iterable of iterable of tuple of number \
    or iterable of iterable of imgaug.augmentables.kps.Keypoint \
    or iterable of iterable of imgaug.augmentables.lines.LineString \
    or iterable of iterable of iterable of tuple of number \
    or iterable of iterable of iterable of tuple of \
    imgaug.augmentables.kps.Keypoint, \
    optional
    The line strings to augment.
    See `polygons`, which behaves similarly.

return_batch : bool, optional
    Whether to return an instance of
    `imgaug.augmentables.batches.UnnormalizedBatch`. If the python
    version is below 3.6 and more than two augmentables were provided
    (e.g. images, keypoints and polygons), then this must be set to
    ``True``. Otherwise an error will be raised.

hooks : None or imgaug.imgaug.HooksImages, optional
    Hooks object to dynamically interfere with the augmentation process.

Returns
-------
tuple or imgaug.augmentables.batches.UnnormalizedBatch
    If `return_batch` was set to ``True``, a instance of
    ``UnnormalizedBatch`` will be returned.
    If `return_batch` was set to ``False``, a tuple of augmentables
    will be returned, e.g. ``(augmented images, augmented keypoints)``.
    The datatypes match the input datatypes of the corresponding named
    arguments. In python <3.6, augmented images are always the first
    entry in the returned tuple. In python 3.6+ the order matches the
    order of the named arguments.

Examples
--------
>>> import numpy as np
>>> import imgaug as ia
>>> import imgaug.augmenters as iaa
>>> aug = iaa.Affine(rotate=(-25, 25))
>>> image = np.zeros((64, 64, 3), dtype=np.uint8)
>>> keypoints = [(10, 20), (30, 32)]  # (x,y) coordinates
>>> images_aug, keypoints_aug = aug.augment(
>>>     image=image, keypoints=keypoints)

This creates a single image and a set of two keypoints on it, then
augments both by applying a random rotation between -25deg and +25deg.
The sampled rotation value is automatically aligned between image and
keypoints. Note that in python <3.6, augmented images will always be
returned first, independent of the order of the named input arguments.
So ``keypoints_aug, images_aug = aug.augment(keypoints=keypoints,
image=image)`` would _not_ work (except in python 3.6+).

>>> import numpy as np
>>> import imgaug as ia
>>> import imgaug.augmenters as iaa
>>> aug = iaa.Affine(rotate=(-25, 25))
>>> images = [np.zeros((64, 64, 3), dtype=np.uint8),
>>>           np.zeros((32, 32, 3), dtype=np.uint8)]
>>> keypoints = [[(10, 20), (30, 32)],  # KPs on first image
>>>              [(22, 10), (12, 14)]]  # KPs on second image
>>> bbs = [
>>>           [ia.BoundingBox(x1=5, y1=5, x2=50, y2=45)],
>>>           [ia.BoundingBox(x1=4, y1=6, x2=10, y2=15),
>>>            ia.BoundingBox(x1=8, y1=9, x2=16, y2=30)]
>>>       ]  # one BB on first image, two BBs on second image
>>> batch_aug = aug.augment(
>>>     images=images, keypoints=keypoints, bounding_boxes=bbs,
>>>     return_batch=True)

This creates two images of size 64x64 and 32x32, two sets of keypoints
(each containing two keypoints) and two sets of bounding boxes (the
first containing one bounding box, the second two bounding boxes).
These augmentables are then augmented by applying random rotations
between -25deg and +25deg to them. The rotation values are sampled
by image and aligned between all augmentables on the same image.
The method finally returns an instance of ``UnnormalizedBatch`` from
which the augmented data can be retrieved via ``batch_aug.images_aug``,
``batch_aug.keypoints_aug``, and ``batch_aug.bounding_boxes_aug``.
In python 3.6+, `return_batch` can be kept at ``False`` and the
augmented data can be retrieved as
``images_aug, keypoints_aug, bbs_aug = augment(...)``.


return self.augment(*args, **kwargs)<EOL>


def pool(self, processes=None, maxtasksperchild=None, seed=None):

import imgaug.multicore as multicore<EOL>return multicore.Pool(self, processes=processes, maxtasksperchild=maxtasksperchild, seed=seed)<EOL>

Create a pool used for multicore augmentation from this augmenter.

Parameters
----------
processes : None or int, optional
    Same as for :func:`imgaug.multicore.Pool.__init__`.
    The number of background workers, similar to the same parameter in multiprocessing.Pool.
    If ``None``, the number of the machine's CPU cores will be used (this counts hyperthreads as CPU cores).
    If this is set to a negative value ``p``, then ``P - abs(p)`` will be used, where ``P`` is the number
    of CPU cores. E.g. ``-1`` would use all cores except one (this is useful to e.g. reserve one core to
    feed batches to the GPU).

maxtasksperchild : None or int, optional
    Same as for :func:`imgaug.multicore.Pool.__init__`.
    The number of tasks done per worker process before the process is killed and restarted, similar to the
    same parameter in multiprocessing.Pool. If ``None``, worker processes will not be automatically restarted.

seed : None or int, optional
    Same as for :func:`imgaug.multicore.Pool.__init__`.
    The seed to use for child processes. If ``None``, a random seed will be used.

Returns
-------
imgaug.multicore.Pool
    Pool for multicore augmentation.

Examples
--------
>>> import imgaug as ia
>>> from imgaug import augmenters as iaa
>>> import numpy as np
>>> aug = iaa.Add(1)
>>> images = np.zeros((16, 128, 128, 3), dtype=np.uint8)
>>> batches = [ia.Batch(images=np.copy(images)) for _ in range(100)]
>>> with aug.pool(processes=-1, seed=2) as pool:
>>>     batches_aug = pool.map_batches(batches, chunksize=8)
>>> print(np.sum(batches_aug[0].images_aug[0]))
49152

Creates ``100`` batches of empty images. Each batch contains ``16`` images of size ``128x128``. The batches
are then augmented on all CPU cores except one (``processes=-1``). After augmentation, the sum of pixel values
from the first augmented image is printed.

>>> import imgaug as ia
>>> from imgaug import augmenters as iaa
>>> import numpy as np
>>> aug = iaa.Add(1)
>>> images = np.zeros((16, 128, 128, 3), dtype=np.uint8)
>>> def generate_batches():
>>>     for _ in range(100):
>>>         yield ia.Batch(images=np.copy(images))
>>>
>>> with aug.pool(processes=-1, seed=2) as pool:
>>>     batches_aug = pool.imap_batches(generate_batches(), chunksize=8)
>>>     batch_aug = next(batches_aug)
>>>     print(np.sum(batch_aug.images_aug[0]))
49152

Same as above. This time, a generator is used to generate batches of images. Again, the first augmented image's
sum of pixels is printed.


def draw_grid(self, images, rows, cols):

if ia.is_np_array(images):<EOL><INDENT>if len(images.shape) == <NUM_LIT:4>:<EOL><INDENT>images = [images[i] for i in range(images.shape[<NUM_LIT:0>])]<EOL><DEDENT>elif len(images.shape) == <NUM_LIT:3>:<EOL><INDENT>images = [images]<EOL><DEDENT>elif len(images.shape) == <NUM_LIT:2>:<EOL><INDENT>images = [images[:, :, np.newaxis]]<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>+ "<STR_LIT>" % (images.shape,))<EOL><DEDENT><DEDENT>elif isinstance(images, list):<EOL><INDENT>for i, image in enumerate(images):<EOL><INDENT>if len(image.shape) == <NUM_LIT:3>:<EOL><INDENT>continue<EOL><DEDENT>elif len(image.shape) == <NUM_LIT:2>:<EOL><INDENT>images[i] = image[:, :, np.newaxis]<EOL><DEDENT>else:<EOL><INDENT>raise Exception(("<STR_LIT>"<EOL>+ "<STR_LIT>") % (i, image.shape,))<EOL><DEDENT><DEDENT><DEDENT>ia.do_assert(isinstance(images, list))<EOL>det = self if self.deterministic else self.to_deterministic()<EOL>augs = []<EOL>for image in images:<EOL><INDENT>augs.append(det.augment_images([image] * (rows * cols)))<EOL><DEDENT>augs_flat = list(itertools.chain(*augs))<EOL>cell_height = max([image.shape[<NUM_LIT:0>] for image in augs_flat])<EOL>cell_width = max([image.shape[<NUM_LIT:1>] for image in augs_flat])<EOL>width = cell_width * cols<EOL>height = cell_height * (rows * len(images))<EOL>grid = np.zeros((height, width, <NUM_LIT:3>), dtype=augs[<NUM_LIT:0>][<NUM_LIT:0>].dtype)<EOL>for row_idx in range(rows):<EOL><INDENT>for img_idx, image in enumerate(images):<EOL><INDENT>for col_idx in range(cols):<EOL><INDENT>image_aug = augs[img_idx][(row_idx * cols) + col_idx]<EOL>cell_y1 = cell_height * (row_idx * len(images) + img_idx)<EOL>cell_y2 = cell_y1 + image_aug.shape[<NUM_LIT:0>]<EOL>cell_x1 = cell_width * col_idx<EOL>cell_x2 = cell_x1 + image_aug.shape[<NUM_LIT:1>]<EOL>grid[cell_y1:cell_y2, cell_x1:cell_x2, :] = image_aug<EOL><DEDENT><DEDENT><DEDENT>return grid<EOL>

Apply this augmenter to the given images and return a grid image of the results.
Each cell in the grid contains a single augmented variation of an input image.

If multiple images are provided, the row count is multiplied by
the number of images and each image gets its own row.
E.g. for ``images = [A, B]``, ``rows=2``, ``cols=3``::

    A A A
    B B B
    A A A
    B B B

for ``images = [A]``, ``rows=2``,
``cols=3``::

    A A A
    A A A

Parameters
-------
images : (N,H,W,3) ndarray or (H,W,3) ndarray or (H,W) ndarray or list of (H,W,3) ndarray\
         or list of (H,W) ndarray
    List of images of which to show the augmented versions.
    If a list, then each element is expected to have shape ``(H, W)`` or
    ``(H, W, 3)``. If a single array, then it is expected to have
    shape ``(N, H, W, 3)`` or ``(H, W, 3)`` or ``(H, W)``.

rows : int
    Number of rows in the grid.
    If ``N`` input images are given, this value will automatically be
    multiplied by ``N`` to create rows for each image.

cols : int
    Number of columns in the grid.

Returns
-------
grid : (Hg, Wg, 3) ndarray
    The generated grid image with augmented versions of the input
    images. Here, ``Hg`` and ``Wg`` reference the output size of the grid,
    and *not* the sizes of the input images.


def show_grid(self, images, rows, cols):

grid = self.draw_grid(images, rows, cols)<EOL>ia.imshow(grid)<EOL>

Apply this augmenter to the given images and show/plot the results as a grid of images.

If multiple images are provided, the row count is multiplied by
the number of images and each image gets its own row.
E.g. for ``images = [A, B]``, ``rows=2``, ``cols=3``::

    A A A
    B B B
    A A A
    B B B

for ``images = [A]``, ``rows=2``,
``cols=3``::

    A A A
    A A A

Parameters
----------
images : (N,H,W,3) ndarray or (H,W,3) ndarray or (H,W) ndarray or list of (H,W,3) ndarray\
         or list of (H,W) ndarray
    List of images of which to show the augmented versions.
    If a list, then each element is expected to have shape ``(H, W)`` or ``(H, W, 3)``.
    If a single array, then it is expected to have shape ``(N, H, W, 3)``
    or ``(H, W, 3)`` or ``(H, W)``.

rows : int
    Number of rows in the grid.
    If ``N`` input images are given, this value will automatically be
    multiplied by ``N`` to create rows for each image.

cols : int
    Number of columns in the grid.


ia.do_assert(n is None or n >= <NUM_LIT:1>)<EOL>if n is None:<EOL><INDENT>return self.to_deterministic(<NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return [self._to_deterministic() for _ in sm.xrange(n)]<EOL><DEDENT>

Converts this augmenter from a stochastic to a deterministic one.

A stochastic augmenter samples new values for each parameter per image.
Feed a new batch of images into the augmenter and you will get a
new set of transformations.
A deterministic augmenter also samples new values for each parameter
per image, but starts each batch with the same RandomState (i.e. seed).
Feed two batches of images into the augmenter and you get the same
transformations both times (same number of images assumed; some
augmenter's results are also dependend on image height, width and
channel count).

Using determinism is useful for keypoint augmentation,
as you will usually want to augment images and their corresponding
keypoints in the same way (e.g. if an image is rotated by ``30deg``, then
also rotate its keypoints by ``30deg``).

Parameters
----------
n : None or int, optional
    Number of deterministic augmenters to return.
    If None then only one Augmenter object will be returned.
    If 1 or higher, then a list containing `n` Augmenter objects
    will be returned.

Returns
-------
det : imgaug.augmenters.meta.Augmenter or list of imgaug.augmenters.meta.Augmenter
    A single Augmenter object if `n` was None,
    otherwise a list of Augmenter objects (even if `n` was 1).


aug = self.copy()<EOL>aug.random_state = ia.derive_random_state(self.random_state)<EOL>aug.deterministic = True<EOL>return aug<EOL>

Augmenter-specific implementation of ``to_deterministic()``.
This function is expected to return a single new deterministic
Augmenter object of this augmenter.

Returns
-------
det : imgaug.augmenters.meta.Augmenter
    Deterministic variation of this Augmenter object.


def reseed(self, random_state=None, deterministic_too=False):

ia.do_assert(isinstance(deterministic_too, bool))<EOL>if random_state is None:<EOL><INDENT>random_state = ia.current_random_state()<EOL><DEDENT>elif isinstance(random_state, np.random.RandomState):<EOL><INDENT>pass  <EOL><DEDENT>else:<EOL><INDENT>random_state = ia.new_random_state(random_state)<EOL><DEDENT>if not self.deterministic or deterministic_too:<EOL><INDENT>seed = random_state.randint(<NUM_LIT:0>, <NUM_LIT:10>**<NUM_LIT:6>, <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>self.random_state = ia.new_random_state(seed)<EOL><DEDENT>for lst in self.get_children_lists():<EOL><INDENT>for aug in lst:<EOL><INDENT>aug.reseed(random_state=random_state, deterministic_too=deterministic_too)<EOL><DEDENT><DEDENT>

Reseed this augmenter and all of its children (if it has any).

This function is useful, when augmentations are run in the
background (i.e. on multiple cores).
It should be called before sending this Augmenter object to a
background worker or once within each worker with different seeds
(i.e., if ``N`` workers are used, the function should be called
``N`` times). Otherwise, all background workers will
use the same seeds and therefore apply the same augmentations.

If this augmenter or any child augmenter had a random state that
pointed to the global random state, it will automatically be
replaced with a local random state. This is similar to what
:func:`imgaug.augmenters.meta.Augmenter.localize_random_state`
does.

Parameters
----------
random_state : None or int or numpy.random.RandomState, optional
    A RandomState that is used to sample seeds per augmenter.
    If int, the parameter will be used as a seed for a new RandomState.
    If None, a new RandomState will automatically be created.

deterministic_too : bool, optional
    Whether to also change the seed of an augmenter ``A``, if ``A``
    is deterministic. This is the case both when this augmenter
    object is ``A`` or one of its children is ``A``.


aug = self.deepcopy()<EOL>aug.localize_random_state_(<EOL>recursive=recursive<EOL>)<EOL>return aug<EOL>

Converts global random states to local ones.
See :func:`Augmenter.localize_random_state_` for more details.

Parameters
----------
recursive : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.localize_random_state_`.

Returns
-------
aug : imgaug.augmenters.meta.Augmenter
    Returns copy of augmenter and children, with localized random states.


if self.random_state == ia.current_random_state():<EOL><INDENT>self.random_state = ia.new_random_state()<EOL><DEDENT>if recursive:<EOL><INDENT>for lst in self.get_children_lists():<EOL><INDENT>for child in lst:<EOL><INDENT>child.localize_random_state_(recursive=recursive)<EOL><DEDENT><DEDENT><DEDENT>return self<EOL>

Converts global random states to local ones.

A global random state exists exactly once. Many augmenters can point
to it (and thereby use it to sample random numbers).
Local random states usually exist for exactly one augmenter and are
saved within that augmenter.

Usually there is no need to change global into local random states.
The only noteworthy exceptions are

    * whenever you want to use determinism (so that the global random
      state is not accidentally reverted)
    * whenever you want to copy random states from one augmenter to
      another. (Copying the global random state doesn't help very
      much. If you copy the state from A to B, then execute A and then
      B, B's (global) random state has already changed because of A's
      sampling.)

The case of determinism is handled automatically by
:func:`imgaug.augmenters.meta.Augmenter.to_deterministic`.
Only when you copy random states (via :func:`imgaug.augmenters.meta.Augmenter.copy_random_state`),
you need to call this function first.

Parameters
----------
recursive : bool, optional
    Whether to localize the random states of children too.

Returns
-------
self : imgaug.augmenters.meta.Augmenter
    Returns itself (with localized random states).


def copy_random_state(self, source, recursive=True, matching="<STR_LIT>", matching_tolerant=True,<EOL>copy_determinism=False):

Copy the random states from a source augmenter sequence.

Parameters
----------
source : imgaug.augmenters.meta.Augmenter
    See :func:`imgaug.augmenters.meta.Augmenter.copy_random_state_`.

recursive : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.copy_random_state_`.

matching : {'position', 'name'}, optional
    See :func:`imgaug.augmenters.meta.Augmenter.copy_random_state_`.

matching_tolerant : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.copy_random_state_`.

copy_determinism : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.copy_random_state_`.

Returns
-------
aug : imgaug.augmenters.meta.Augmenter
    Copy of the augmenter(s) with the same random state(s) as in the
    source augmenter(s).


def copy_random_state_(self, source, recursive=True, matching="<STR_LIT>", matching_tolerant=True,<EOL>copy_determinism=False):

source_augs = [source] + source.get_all_children(flat=True) if recursive else [source]<EOL>target_augs = [self] + self.get_all_children(flat=True) if recursive else [self]<EOL>global_rs = ia.current_random_state()<EOL>global_rs_exc_msg = "<STR_LIT>""<STR_LIT>""<STR_LIT>""<STR_LIT>""<STR_LIT>"<EOL>if matching == "<STR_LIT:name>":<EOL><INDENT>source_augs_dict = {aug.name: aug for aug in source_augs}<EOL>target_augs_dict = {aug.name: aug for aug in target_augs}<EOL>if len(source_augs_dict) < len(source_augs) or len(target_augs_dict) < len(target_augs):<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>for name in target_augs_dict:<EOL><INDENT>if name in source_augs_dict:<EOL><INDENT>if source_augs_dict[name].random_state == global_rs:<EOL><INDENT>raise Exception(global_rs_exc_msg)<EOL><DEDENT>target_augs_dict[name].random_state = ia.copy_random_state(source_augs_dict[name].random_state)<EOL>if copy_determinism:<EOL><INDENT>target_augs_dict[name].deterministic = source_augs_dict[name].deterministic<EOL><DEDENT><DEDENT>elif not matching_tolerant:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>" % (name,)<EOL>)<EOL><DEDENT><DEDENT><DEDENT>elif matching == "<STR_LIT>":<EOL><INDENT>if len(source_augs) != len(target_augs) and not matching_tolerant:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>for source_aug, target_aug in zip(source_augs, target_augs):<EOL><INDENT>if source_aug.random_state == global_rs:<EOL><INDENT>raise Exception(global_rs_exc_msg)<EOL><DEDENT>target_aug.random_state = ia.copy_random_state(source_aug.random_state, force_copy=True)<EOL>if copy_determinism:<EOL><INDENT>target_aug.deterministic = source_aug.deterministic<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % (matching,))<EOL><DEDENT>return self<EOL>

Copy the random states from a source augmenter sequence (inplace).

Parameters
----------
source : imgaug.augmenters.meta.Augmenter
    The source augmenter from where to copy the random_state(s).
    May have children (e.g. a Sequential).
    May not use the global random state. This is used by default
    by all augmenters. Call :func:`imgaug.augmenters.meta.Augmenter.localize_random_state_`
    once on the source to localize all random states.

recursive : bool, optional
    Whether to copy the random states of the source augmenter *and*
    all of its children (True) or just the source augmenter (False).

matching : {'position', 'name'}, optional
    Defines the matching mode to use during recursive copy.
    This is used to associate source augmenters with target augmenters.
    If ``position`` then the target and source sequences of augmenters
    are turned into flattened lists and are associated based on
    their list indices. If ``name`` then the target and source augmenters
    are matched based on their names (i.e. ``augmenter.name``).

matching_tolerant : bool, optional
    Whether to use tolerant matching between source and target
    augmenters. If set to False: Name matching will raise an exception
    for any target augmenter which's name does not appear among the
    source augmeters. Position matching will raise an exception if
    source and target augmenter have an unequal number of children.

copy_determinism : bool, optional
    Whether to copy the ``deterministic`` flags from source to target
    augmenters too.

Returns
-------
self : imgaug.augmenters.meta.Augmenter
    Returns itself (after random state copy).


return []<EOL>

Get a list of lists of children of this augmenter.

For most augmenters, the result will be a single empty list.
For augmenters with children it will often be a list with one sublist containing all
children. In some cases the augmenter will contain multiple distinct lists of children,
e.g. an if-list and an else-list. This will lead to a result consisting of a single
list with multiple sublists, each representing the respective sublist of children.

E.g. for an if/else-augmenter that executes the children ``A1``, ``A2`` if a condition is met
and otherwise executes the children ``B1``, ``B2``, ``B3`` the result will
be ``[[A1, A2], [B1, B2, B3]]``.

IMPORTANT: While the topmost list may be newly created, each of the sublist must be
editable inplace resulting in a changed children list of the augmenter. E.g. if
an Augmenter ``IfElse(condition, [A1, A2], [B1, B2, B3])`` returns ``[[A1, A2], [B1, B2, B3]]``
for a call to :func:`imgaug.augmenters.meta.Augmenter.get_children_lists` and
``A2`` is removed inplace from ``[A1, A2]``, then the
children lists of ``IfElse(...)`` must also change to ``[A1], [B1, B2, B3]``. This is used
in :func:`imgaug.augmeneters.meta.Augmenter.remove_augmenters_inplace`.

Returns
-------
children : list of list of imgaug.augmenters.meta.Augmenter
    One or more lists of child augmenter.
    Can also be a single empty list.


result = []<EOL>for lst in self.get_children_lists():<EOL><INDENT>for aug in lst:<EOL><INDENT>result.append(aug)<EOL>children = aug.get_all_children(flat=flat)<EOL>if len(children) > <NUM_LIT:0>:<EOL><INDENT>if flat:<EOL><INDENT>result.extend(children)<EOL><DEDENT>else:<EOL><INDENT>result.append(children)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>

Returns all children of this augmenter as a list.

If the augmenter has no children, the returned list is empty.

Parameters
----------
flat : bool
    If set to True, the returned list will be flat.

Returns
-------
result : list of imgaug.augmenters.meta.Augmenter
    The children as a nested or flat list.


def find_augmenters(self, func, parents=None, flat=True):

if parents is None:<EOL><INDENT>parents = []<EOL><DEDENT>result = []<EOL>if func(self, parents):<EOL><INDENT>result.append(self)<EOL><DEDENT>subparents = parents + [self]<EOL>for lst in self.get_children_lists():<EOL><INDENT>for aug in lst:<EOL><INDENT>found = aug.find_augmenters(func, parents=subparents, flat=flat)<EOL>if len(found) > <NUM_LIT:0>:<EOL><INDENT>if flat:<EOL><INDENT>result.extend(found)<EOL><DEDENT>else:<EOL><INDENT>result.append(found)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>

Find augmenters that match a condition.
This function will compare this augmenter and all of its children
with a condition. The condition is a lambda function.

Parameters
----------
func : callable
    A function that receives an Augmenter instance and a list of
    parent Augmenter instances and must return True, if that
    augmenter is valid match.

parents : None or list of imgaug.augmenters.meta.Augmenter, optional
    List of parent augmenters.
    Intended for nested calls and can usually be left as None.

flat : bool, optional
    Whether to return the result as a flat list (True)
    or a nested list (False). In the latter case, the nesting matches
    each augmenters position among the children.

Returns
----------
augmenters : list of imgaug.augmenters.meta.Augmenter
    Nested list if flat was set to False.
    Flat list if flat was set to True.

Examples
--------
>>> aug = iaa.Sequential([
>>>     iaa.Fliplr(0.5, name="fliplr"),
>>>     iaa.Flipud(0.5, name="flipud")
>>> ])
>>> print(aug.find_augmenters(lambda a, parents: a.name == "fliplr"))

This will return the first child augmenter (Fliplr instance).


def find_augmenters_by_name(self, name, regex=False, flat=True):

return self.find_augmenters_by_names([name], regex=regex, flat=flat)<EOL>

Find augmenter(s) by name.

        Parameters
        ----------
        name : str
            Name of the augmenter(s) to search for.

        regex : bool, optional
            Whether `name` parameter is a regular expression.

        flat : bool, optional
            See :func:`imgaug.augmenters.meta.Augmenter.find_augmenters`.

        Returns
        -------
        augmenters : list of imgaug.augmenters.meta.Augmenter
            Nested list if flat was set to False.
            Flat list if flat was set to True.


def find_augmenters_by_names(self, names, regex=False, flat=True):

if regex:<EOL><INDENT>def comparer(aug, parents):<EOL><INDENT>for pattern in names:<EOL><INDENT>if re.match(pattern, aug.name):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL><DEDENT>return self.find_augmenters(comparer, flat=flat)<EOL><DEDENT>else:<EOL><INDENT>return self.find_augmenters(lambda aug, parents: aug.name in names, flat=flat)<EOL><DEDENT>

Find augmenter(s) by names.

Parameters
----------
names : list of str
    Names of the augmenter(s) to search for.

regex : bool, optional
    Whether `names` is a list of regular expressions.

flat : boolean, optional
    See :func:`imgaug.augmenters.meta.Augmenter.find_augmenters`.

Returns
-------
augmenters : list of imgaug.augmenters.meta.Augmenter
    Nested list if flat was set to False.
    Flat list if flat was set to True.


def remove_augmenters(self, func, copy=True, noop_if_topmost=True):

if func(self, []):<EOL><INDENT>if not copy:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if noop_if_topmost:<EOL><INDENT>return Noop()<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>aug = self if not copy else self.deepcopy()<EOL>aug.remove_augmenters_inplace(func, parents=[])<EOL>return aug<EOL><DEDENT>

Remove this augmenter or its children that match a condition.

Parameters
----------
func : callable
    Condition to match per augmenter.
    The function must expect the augmenter itself and a list of parent
    augmenters and returns True if that augmenter is to be removed,
    or False otherwise.
    E.g. ``lambda a, parents: a.name == "fliplr" and len(parents) == 1``
    removes an augmenter with name "fliplr" if it is the direct child
    of the augmenter upon which ``remove_augmenters()`` was initially called.

copy : bool, optional
    Whether to copy this augmenter and all if its children before
    removing. If False, removal is performed in-place.

noop_if_topmost : bool, optional
    If True and the condition (lambda function) leads to the removal
    of the topmost augmenter (the one this function is called on
    initially), then that topmost augmenter will be replaced by a
    Noop instance (i.e. an object that will still offer ``augment_images()``,
    but does not change images). If False, None will be returned in
    these cases.
    This can only be False if copy is set to True.

Returns
-------
aug : imgaug.augmenters.meta.Augmenter or None
    This augmenter after the removal was performed.
    Is None iff condition was matched for the topmost augmenter,
    copy was set to True and `noop_if_topmost` was set to False.

Examples
--------
>>> seq = iaa.Sequential([
>>>     iaa.Fliplr(0.5, name="fliplr"),
>>>     iaa.Flipud(0.5, name="flipud"),
>>> ])
>>> seq = seq.remove_augmenters(lambda a, parents: a.name == "fliplr")

This removes the augmenter Fliplr from the Sequential object's children.


def remove_augmenters_inplace(self, func, parents=None):

parents = [] if parents is None else parents<EOL>subparents = parents + [self]<EOL>for lst in self.get_children_lists():<EOL><INDENT>to_remove = []<EOL>for i, aug in enumerate(lst):<EOL><INDENT>if func(aug, subparents):<EOL><INDENT>to_remove.append((i, aug))<EOL><DEDENT><DEDENT>for count_removed, (i, aug) in enumerate(to_remove):<EOL><INDENT>del lst[i - count_removed]<EOL><DEDENT>for aug in lst:<EOL><INDENT>aug.remove_augmenters_inplace(func, subparents)<EOL><DEDENT><DEDENT>

Remove in-place children of this augmenter that match a condition.

This is functionally identical to ``remove_augmenters()`` with
``copy=False``, except that it does not affect the topmost augmenter
(the one on which this function is initially called on).

Parameters
----------
func : callable
    See :func:`imgaug.augmenters.meta.Augmenter.remove_augmenters`.

parents : None or list of imgaug.augmenters.meta.Augmenter, optional
    List of parent Augmenter instances that lead to this
    Augmenter. If None, an empty list will be used.
    This parameter can usually be left empty and will be set
    automatically for children.

Examples
--------
>>> seq = iaa.Sequential([
>>>     iaa.Fliplr(0.5, name="fliplr"),
>>>    iaa.Flipud(0.5, name="flipud"),
>>> ])
>>> seq.remove_augmenters_inplace(lambda a, parents: a.name == "fliplr")

This removes the augmenter Fliplr from the Sequential object's children.


return copy_module.copy(self)<EOL>

Create a shallow copy of this Augmenter instance.

Returns
-------
imgaug.augmenters.meta.Augmenter
    Shallow copy of this Augmenter instance.


return copy_module.deepcopy(self)<EOL>

Create a deep copy of this Augmenter instance.

Returns
-------
imgaug.augmenters.meta.Augmenter
    Deep copy of this Augmenter instance.


self.append(augmenter)<EOL>

Add an augmenter to the list of child augmenters.

        Parameters
        ----------
        augmenter : imgaug.augmenters.meta.Augmenter
            The augmenter to add.


self.append(augmenter)<EOL>


<EOL>if arr.dtype.name == "<STR_LIT>":<EOL><INDENT>min_value, _center_value, max_value = iadt.get_value_range_of_dtype(arr.dtype)<EOL>dynamic_range = max_value - min_value<EOL>value_range = np.linspace(<NUM_LIT:0>, <NUM_LIT:1.0>, num=dynamic_range+<NUM_LIT:1>, dtype=np.float32)<EOL>table = (min_value + (value_range ** np.float32(gamma)) * dynamic_range)<EOL>arr_aug = cv2.LUT(arr, np.clip(table, min_value, max_value).astype(arr.dtype))<EOL>if arr.ndim == <NUM_LIT:3> and arr_aug.ndim == <NUM_LIT:2>:<EOL><INDENT>return arr_aug[..., np.newaxis]<EOL><DEDENT>return arr_aug<EOL><DEDENT>else:<EOL><INDENT>return ski_exposure.adjust_gamma(arr, gamma)<EOL><DEDENT>

Adjust contrast by scaling each pixel value to ``255 * ((I_ij/255)**gamma)``.

dtype support::

    * ``uint8``: yes; fully tested (1) (2) (3)
    * ``uint16``: yes; tested (2) (3)
    * ``uint32``: yes; tested (2) (3)
    * ``uint64``: yes; tested (2) (3) (4)
    * ``int8``: limited; tested (2) (3) (5)
    * ``int16``: limited; tested (2) (3) (5)
    * ``int32``: limited; tested (2) (3) (5)
    * ``int64``: limited; tested (2) (3) (4) (5)
    * ``float16``: limited; tested (5)
    * ``float32``: limited; tested (5)
    * ``float64``: limited; tested (5)
    * ``float128``: no (6)
    * ``bool``: no (7)

    - (1) Handled by ``cv2``. Other dtypes are handled by ``skimage``.
    - (2) Normalization is done as ``I_ij/max``, where ``max`` is the maximum value of the
          dtype, e.g. 255 for ``uint8``. The normalization is reversed afterwards,
          e.g. ``result*255`` for ``uint8``.
    - (3) Integer-like values are not rounded after applying the contrast adjustment equation
          (before inverting the normalization to 0.0-1.0 space), i.e. projection from continuous
          space to discrete happens according to floor function.
    - (4) Note that scikit-image doc says that integers are converted to ``float64`` values before
          applying the contrast normalization method. This might lead to inaccuracies for large
          64bit integer values. Tests showed no indication of that happening though.
    - (5) Must not contain negative values. Values >=0 are fully supported.
    - (6) Leads to error in scikit-image.
    - (7) Does not make sense for contrast adjustments.

Parameters
----------
arr : numpy.ndarray
    Array for which to adjust the contrast. Dtype ``uint8`` is fastest.

gamma : number
    Exponent for the contrast adjustment. Higher values darken the image.

Returns
-------
numpy.ndarray
    Array with adjusted contrast.


def adjust_contrast_sigmoid(arr, gain, cutoff):

<EOL>if arr.dtype.name == "<STR_LIT>":<EOL><INDENT>min_value, _center_value, max_value = iadt.get_value_range_of_dtype(arr.dtype)<EOL>dynamic_range = max_value - min_value<EOL>value_range = np.linspace(<NUM_LIT:0>, <NUM_LIT:1.0>, num=dynamic_range+<NUM_LIT:1>, dtype=np.float32)<EOL>gain = np.float32(gain)<EOL>cutoff = np.float32(cutoff)<EOL>table = min_value + dynamic_range * <NUM_LIT:1>/(<NUM_LIT:1> + np.exp(gain * (cutoff - value_range)))<EOL>arr_aug = cv2.LUT(arr, np.clip(table, min_value, max_value).astype(arr.dtype))<EOL>if arr.ndim == <NUM_LIT:3> and arr_aug.ndim == <NUM_LIT:2>:<EOL><INDENT>return arr_aug[..., np.newaxis]<EOL><DEDENT>return arr_aug<EOL><DEDENT>else:<EOL><INDENT>return ski_exposure.adjust_sigmoid(arr, cutoff=cutoff, gain=gain)<EOL><DEDENT>

Adjust contrast by scaling each pixel value to ``255 * 1/(1 + exp(gain*(cutoff - I_ij/255)))``.

dtype support::

    * ``uint8``: yes; fully tested (1) (2) (3)
    * ``uint16``: yes; tested (2) (3)
    * ``uint32``: yes; tested (2) (3)
    * ``uint64``: yes; tested (2) (3) (4)
    * ``int8``: limited; tested (2) (3) (5)
    * ``int16``: limited; tested (2) (3) (5)
    * ``int32``: limited; tested (2) (3) (5)
    * ``int64``: limited; tested (2) (3) (4) (5)
    * ``float16``: limited; tested (5)
    * ``float32``: limited; tested (5)
    * ``float64``: limited; tested (5)
    * ``float128``: no (6)
    * ``bool``: no (7)

    - (1) Handled by ``cv2``. Other dtypes are handled by ``skimage``.
    - (2) Normalization is done as ``I_ij/max``, where ``max`` is the maximum value of the
          dtype, e.g. 255 for ``uint8``. The normalization is reversed afterwards,
          e.g. ``result*255`` for ``uint8``.
    - (3) Integer-like values are not rounded after applying the contrast adjustment equation
          (before inverting the normalization to 0.0-1.0 space), i.e. projection from continuous
          space to discrete happens according to floor function.
    - (4) Note that scikit-image doc says that integers are converted to ``float64`` values before
          applying the contrast normalization method. This might lead to inaccuracies for large
          64bit integer values. Tests showed no indication of that happening though.
    - (5) Must not contain negative values. Values >=0 are fully supported.
    - (6) Leads to error in scikit-image.
    - (7) Does not make sense for contrast adjustments.

Parameters
----------
arr : numpy.ndarray
    Array for which to adjust the contrast. Dtype ``uint8`` is fastest.

gain : number
    Multiplier for the sigmoid function's output.
    Higher values lead to quicker changes from dark to light pixels.

cutoff : number
    Cutoff that shifts the sigmoid function in horizontal direction.
    Higher values mean that the switch from dark to light pixels happens later, i.e.
    the pixels will remain darker.

Returns
-------
numpy.ndarray
    Array with adjusted contrast.


<EOL>if arr.dtype.name == "<STR_LIT>":<EOL><INDENT>min_value, _center_value, max_value = iadt.get_value_range_of_dtype(arr.dtype)<EOL>dynamic_range = max_value - min_value<EOL>value_range = np.linspace(<NUM_LIT:0>, <NUM_LIT:1.0>, num=dynamic_range+<NUM_LIT:1>, dtype=np.float32)<EOL>gain = np.float32(gain)<EOL>table = min_value + dynamic_range * gain * np.log2(<NUM_LIT:1> + value_range)<EOL>arr_aug = cv2.LUT(arr, np.clip(table, min_value, max_value).astype(arr.dtype))<EOL>if arr.ndim == <NUM_LIT:3> and arr_aug.ndim == <NUM_LIT:2>:<EOL><INDENT>return arr_aug[..., np.newaxis]<EOL><DEDENT>return arr_aug<EOL><DEDENT>else:<EOL><INDENT>return ski_exposure.adjust_log(arr, gain=gain)<EOL><DEDENT>

Adjust contrast by scaling each pixel value to ``255 * gain * log_2(1 + I_ij/255)``.

dtype support::

    * ``uint8``: yes; fully tested (1) (2) (3)
    * ``uint16``: yes; tested (2) (3)
    * ``uint32``: yes; tested (2) (3)
    * ``uint64``: yes; tested (2) (3) (4)
    * ``int8``: limited; tested (2) (3) (5)
    * ``int16``: limited; tested (2) (3) (5)
    * ``int32``: limited; tested (2) (3) (5)
    * ``int64``: limited; tested (2) (3) (4) (5)
    * ``float16``: limited; tested (5)
    * ``float32``: limited; tested (5)
    * ``float64``: limited; tested (5)
    * ``float128``: no (6)
    * ``bool``: no (7)

    - (1) Handled by ``cv2``. Other dtypes are handled by ``skimage``.
    - (2) Normalization is done as ``I_ij/max``, where ``max`` is the maximum value of the
          dtype, e.g. 255 for ``uint8``. The normalization is reversed afterwards,
          e.g. ``result*255`` for ``uint8``.
    - (3) Integer-like values are not rounded after applying the contrast adjustment equation
          (before inverting the normalization to 0.0-1.0 space), i.e. projection from continuous
          space to discrete happens according to floor function.
    - (4) Note that scikit-image doc says that integers are converted to ``float64`` values before
          applying the contrast normalization method. This might lead to inaccuracies for large
          64bit integer values. Tests showed no indication of that happening though.
    - (5) Must not contain negative values. Values >=0 are fully supported.
    - (6) Leads to error in scikit-image.
    - (7) Does not make sense for contrast adjustments.

Parameters
----------
arr : numpy.ndarray
    Array for which to adjust the contrast. Dtype ``uint8`` is fastest.

gain : number
    Multiplier for the logarithm result. Values around 1.0 lead to a contrast-adjusted
    images. Values above 1.0 quickly lead to partially broken images due to exceeding the
    datatype's value range.

Returns
-------
numpy.ndarray
    Array with adjusted contrast.


<EOL>if arr.dtype.name == "<STR_LIT>":<EOL><INDENT>min_value, center_value, max_value = iadt.get_value_range_of_dtype(arr.dtype)<EOL>value_range = np.arange(<NUM_LIT:0>, <NUM_LIT>, dtype=np.float32)<EOL>alpha = np.float32(alpha)<EOL>table = center_value + alpha * (value_range - center_value)<EOL>arr_aug = cv2.LUT(arr, np.clip(table, min_value, max_value).astype(arr.dtype))<EOL>if arr.ndim == <NUM_LIT:3> and arr_aug.ndim == <NUM_LIT:2>:<EOL><INDENT>return arr_aug[..., np.newaxis]<EOL><DEDENT>return arr_aug<EOL><DEDENT>else:<EOL><INDENT>input_dtype = arr.dtype<EOL>_min_value, center_value, _max_value = iadt.get_value_range_of_dtype(input_dtype)<EOL>if input_dtype.kind in ["<STR_LIT:u>", "<STR_LIT:i>"]:<EOL><INDENT>center_value = int(center_value)<EOL><DEDENT>image_aug = center_value + alpha * (arr.astype(np.float64)-center_value)<EOL>image_aug = iadt.restore_dtypes_(image_aug, input_dtype)<EOL>return image_aug<EOL><DEDENT>

Adjust contrast by scaling each pixel value to ``127 + alpha*(I_ij-127)``.

    dtype support::

        * ``uint8``: yes; fully tested (1) (2)
        * ``uint16``: yes; tested (2)
        * ``uint32``: yes; tested (2)
        * ``uint64``: no (3)
        * ``int8``: yes; tested (2)
        * ``int16``: yes; tested (2)
        * ``int32``: yes; tested (2)
        * ``int64``: no (2)
        * ``float16``: yes; tested (2)
        * ``float32``: yes; tested (2)
        * ``float64``: yes; tested (2)
        * ``float128``: no (2)
        * ``bool``: no (4)

        - (1) Handled by ``cv2``. Other dtypes are handled by raw ``numpy``.
        - (2) Only tested for reasonable alphas with up to a value of around 100.
        - (3) Conversion to ``float64`` is done during augmentation, hence ``uint64``, ``int64``,
              and ``float128`` support cannot be guaranteed.
        - (4) Does not make sense for contrast adjustments.

    Parameters
    ----------
    arr : numpy.ndarray
        Array for which to adjust the contrast. Dtype ``uint8`` is fastest.

    alpha : number
        Multiplier to linearly pronounce (>1.0), dampen (0.0 to 1.0) or invert (<0.0) the
        difference between each pixel value and the center value, e.g. ``127`` for ``uint8``.

    Returns
    -------
    numpy.ndarray
        Array with adjusted contrast.


def GammaContrast(gamma=<NUM_LIT:1>, per_channel=False, name=None, deterministic=False, random_state=None):

params1d = [iap.handle_continuous_param(gamma, "<STR_LIT>", value_range=None, tuple_to_uniform=True,<EOL>list_to_choice=True)]<EOL>func = adjust_contrast_gamma<EOL>return _ContrastFuncWrapper(<EOL>func, params1d, per_channel,<EOL>dtypes_allowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>dtypes_disallowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:bool>"],<EOL>name=name if name is not None else ia.caller_name(),<EOL>deterministic=deterministic,<EOL>random_state=random_state<EOL>)<EOL>

Adjust contrast by scaling each pixel value to ``255 * ((I_ij/255)**gamma)``.

Values in the range ``gamma=(0.5, 2.0)`` seem to be sensible.

dtype support::

    See :func:`imgaug.augmenters.contrast.adjust_contrast_gamma`.

Parameters
----------
gamma : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Exponent for the contrast adjustment. Higher values darken the image.

        * If a number, then that value will be used for all images.
        * If a tuple ``(a, b)``, then a value from the range ``[a, b]`` will be used per image.
        * If a list, then a random value will be sampled from that list per image.
        * If a StochasticParameter, then a value will be sampled per image from that parameter.

per_channel :  bool or float, optional
    Whether to use the same value for all channels (False) or to sample a new value for each
    channel (True). If this value is a float ``p``, then for ``p`` percent of all images `per_channel`
    will be treated as True, otherwise as False.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Returns
-------
_ContrastFuncWrapper
    Augmenter to perform gamma contrast adjustment.


def SigmoidContrast(gain=<NUM_LIT:10>, cutoff=<NUM_LIT:0.5>, per_channel=False, name=None, deterministic=False, random_state=None):

<EOL>params1d = [<EOL>iap.handle_continuous_param(gain, "<STR_LIT>", value_range=(<NUM_LIT:0>, None), tuple_to_uniform=True, list_to_choice=True),<EOL>iap.handle_continuous_param(cutoff, "<STR_LIT>", value_range=(<NUM_LIT:0>, <NUM_LIT:1.0>), tuple_to_uniform=True, list_to_choice=True)<EOL>]<EOL>func = adjust_contrast_sigmoid<EOL>return _ContrastFuncWrapper(<EOL>func, params1d, per_channel,<EOL>dtypes_allowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>dtypes_disallowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:bool>"],<EOL>name=name if name is not None else ia.caller_name(),<EOL>deterministic=deterministic,<EOL>random_state=random_state<EOL>)<EOL>

Adjust contrast by scaling each pixel value to ``255 * 1/(1 + exp(gain*(cutoff - I_ij/255)))``.

Values in the range ``gain=(5, 20)`` and ``cutoff=(0.25, 0.75)`` seem to be sensible.

dtype support::

    See :func:`imgaug.augmenters.contrast.adjust_contrast_sigmoid`.

Parameters
----------
gain : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Multiplier for the sigmoid function's output.
    Higher values lead to quicker changes from dark to light pixels.

        * If a number, then that value will be used for all images.
        * If a tuple ``(a, b)``, then a value from the range ``[a, b]`` will be used per image.
        * If a list, then a random value will be sampled from that list per image.
        * If a StochasticParameter, then a value will be sampled per image from that parameter.

cutoff : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Cutoff that shifts the sigmoid function in horizontal direction.
    Higher values mean that the switch from dark to light pixels happens later, i.e.
    the pixels will remain darker.

        * If a number, then that value will be used for all images.
        * If a tuple ``(a, b)``, then a value from the range ``[a, b]`` will be used per image.
        * If a list, then a random value will be sampled from that list per image.
        * If a StochasticParameter, then a value will be sampled per image from that parameter.

per_channel :  bool or float, optional
    Whether to use the same value for all channels (False) or to sample a new value for each
    channel (True). If this value is a float ``p``, then for ``p`` percent of all images `per_channel`
    will be treated as True, otherwise as False.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Returns
-------
_ContrastFuncWrapper
    Augmenter to perform sigmoid contrast adjustment.


def LogContrast(gain=<NUM_LIT:1>, per_channel=False, name=None, deterministic=False, random_state=None):

<EOL>params1d = [iap.handle_continuous_param(gain, "<STR_LIT>", value_range=(<NUM_LIT:0>, None), tuple_to_uniform=True,<EOL>list_to_choice=True)]<EOL>func = adjust_contrast_log<EOL>return _ContrastFuncWrapper(<EOL>func, params1d, per_channel,<EOL>dtypes_allowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>dtypes_disallowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:bool>"],<EOL>name=name if name is not None else ia.caller_name(),<EOL>deterministic=deterministic,<EOL>random_state=random_state<EOL>)<EOL>

Adjust contrast by scaling each pixel value to ``255 * gain * log_2(1 + I_ij/255)``.

dtype support::

    See :func:`imgaug.augmenters.contrast.adjust_contrast_log`.

Parameters
----------
gain : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Multiplier for the logarithm result. Values around 1.0 lead to a contrast-adjusted
    images. Values above 1.0 quickly lead to partially broken images due to exceeding the
    datatype's value range.

        * If a number, then that value will be used for all images.
        * If a tuple ``(a, b)``, then a value from the range ``[a, b]`` will be used per image.
        * If a list, then a random value will be sampled from that list per image.
        * If a StochasticParameter, then a value will be sampled per image from that parameter.

per_channel :  bool or float, optional
    Whether to use the same value for all channels (False) or to sample a new value for each
    channel (True). If this value is a float ``p``, then for ``p`` percent of all images `per_channel`
    will be treated as True, otherwise as False.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Returns
-------
_ContrastFuncWrapper
    Augmenter to perform logarithmic contrast adjustment.


def LinearContrast(alpha=<NUM_LIT:1>, per_channel=False, name=None, deterministic=False, random_state=None):

params1d = [<EOL>iap.handle_continuous_param(alpha, "<STR_LIT>", value_range=None, tuple_to_uniform=True, list_to_choice=True)<EOL>]<EOL>func = adjust_contrast_linear<EOL>return _ContrastFuncWrapper(<EOL>func, params1d, per_channel,<EOL>dtypes_allowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>dtypes_disallowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:bool>"],<EOL>name=name if name is not None else ia.caller_name(),<EOL>deterministic=deterministic,<EOL>random_state=random_state<EOL>)<EOL>

Adjust contrast by scaling each pixel value to ``127 + alpha*(I_ij-127)``.

    dtype support::

        See :func:`imgaug.augmenters.contrast.adjust_contrast_linear`.

    Parameters
    ----------
    alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
        Multiplier to linearly pronounce (>1.0), dampen (0.0 to 1.0) or invert (<0.0) the
        difference between each pixel value and the center value, e.g. ``127`` for ``uint8``.

            * If a number, then that value will be used for all images.
            * If a tuple ``(a, b)``, then a value from the range ``[a, b]`` will be used per image.
            * If a list, then a random value will be sampled from that list per image.
            * If a StochasticParameter, then a value will be sampled per image from that parameter.

    per_channel :  bool or float, optional
        Whether to use the same value for all channels (False) or to sample a new value for each
        channel (True). If this value is a float ``p``, then for ``p`` percent of all images `per_channel`
        will be treated as True, otherwise as False.

    name : None or str, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    deterministic : bool, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    random_state : None or int or numpy.random.RandomState, optional
        See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

    Returns
    -------
    _ContrastFuncWrapper
        Augmenter to perform contrast adjustment by linearly scaling the distance to 128.


def Sharpen(alpha=<NUM_LIT:0>, lightness=<NUM_LIT:1>, name=None, deterministic=False, random_state=None):

alpha_param = iap.handle_continuous_param(alpha, "<STR_LIT>", value_range=(<NUM_LIT:0>, <NUM_LIT:1.0>), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>lightness_param = iap.handle_continuous_param(lightness, "<STR_LIT>", value_range=(<NUM_LIT:0>, None), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>def create_matrices(image, nb_channels, random_state_func):<EOL><INDENT>alpha_sample = alpha_param.draw_sample(random_state=random_state_func)<EOL>ia.do_assert(<NUM_LIT:0> <= alpha_sample <= <NUM_LIT:1.0>)<EOL>lightness_sample = lightness_param.draw_sample(random_state=random_state_func)<EOL>matrix_nochange = np.array([<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]<EOL>], dtype=np.float32)<EOL>matrix_effect = np.array([<EOL>[-<NUM_LIT:1>, -<NUM_LIT:1>, -<NUM_LIT:1>],<EOL>[-<NUM_LIT:1>, <NUM_LIT:8>+lightness_sample, -<NUM_LIT:1>],<EOL>[-<NUM_LIT:1>, -<NUM_LIT:1>, -<NUM_LIT:1>]<EOL>], dtype=np.float32)<EOL>matrix = (<NUM_LIT:1>-alpha_sample) * matrix_nochange + alpha_sample * matrix_effect<EOL>return [matrix] * nb_channels<EOL><DEDENT>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return Convolve(create_matrices, name=name, deterministic=deterministic, random_state=random_state)<EOL>

Augmenter that sharpens images and overlays the result with the original image.

dtype support::

    See ``imgaug.augmenters.convolutional.Convolve``.

Parameters
----------
alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Visibility of the sharpened image. At 0, only the original image is
    visible, at 1.0 only its sharpened version is visible.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list
          per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

lightness : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Parameter that controls the lightness/brightness of the sharped image.
    Sane values are somewhere in the range ``(0.5, 2)``.
    The value 0 results in an edge map. Values higher than 1 create bright
    images. Default value is 1.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list
          per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = Sharpen(alpha=(0.0, 1.0))

sharpens input images and overlays the sharpened image by a variable
amount over the old image.

>>> aug = Sharpen(alpha=(0.0, 1.0), lightness=(0.75, 2.0))

sharpens input images with a variable lightness in the range
``0.75 <= x <= 2.0`` and with a variable alpha.


def Emboss(alpha=<NUM_LIT:0>, strength=<NUM_LIT:1>, name=None, deterministic=False, random_state=None):

alpha_param = iap.handle_continuous_param(alpha, "<STR_LIT>", value_range=(<NUM_LIT:0>, <NUM_LIT:1.0>), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>strength_param = iap.handle_continuous_param(strength, "<STR_LIT>", value_range=(<NUM_LIT:0>, None), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>def create_matrices(image, nb_channels, random_state_func):<EOL><INDENT>alpha_sample = alpha_param.draw_sample(random_state=random_state_func)<EOL>ia.do_assert(<NUM_LIT:0> <= alpha_sample <= <NUM_LIT:1.0>)<EOL>strength_sample = strength_param.draw_sample(random_state=random_state_func)<EOL>matrix_nochange = np.array([<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]<EOL>], dtype=np.float32)<EOL>matrix_effect = np.array([<EOL>[-<NUM_LIT:1>-strength_sample, <NUM_LIT:0>-strength_sample, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>-strength_sample, <NUM_LIT:1>, <NUM_LIT:0>+strength_sample],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>+strength_sample, <NUM_LIT:1>+strength_sample]<EOL>], dtype=np.float32)<EOL>matrix = (<NUM_LIT:1>-alpha_sample) * matrix_nochange + alpha_sample * matrix_effect<EOL>return [matrix] * nb_channels<EOL><DEDENT>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return Convolve(create_matrices, name=name, deterministic=deterministic, random_state=random_state)<EOL>

Augmenter that embosses images and overlays the result with the original
image.

The embossed version pronounces highlights and shadows,
letting the image look as if it was recreated on a metal plate ("embossed").

dtype support::

    See ``imgaug.augmenters.convolutional.Convolve``.

Parameters
----------
alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Visibility of the sharpened image. At 0, only the original image is
    visible, at 1.0 only its sharpened version is visible.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list
          per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

strength : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Parameter that controls the strength of the embossing.
    Sane values are somewhere in the range ``(0, 2)`` with 1 being the standard
    embossing effect. Default value is 1.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list
          per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = Emboss(alpha=(0.0, 1.0), strength=(0.5, 1.5))

embosses an image with a variable strength in the range ``0.5 <= x <= 1.5``
and overlays the result with a variable alpha in the range ``0.0 <= a <= 1.0``
over the old image.


def EdgeDetect(alpha=<NUM_LIT:0>, name=None, deterministic=False, random_state=None):

alpha_param = iap.handle_continuous_param(alpha, "<STR_LIT>", value_range=(<NUM_LIT:0>, <NUM_LIT:1.0>), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>def create_matrices(_image, nb_channels, random_state_func):<EOL><INDENT>alpha_sample = alpha_param.draw_sample(random_state=random_state_func)<EOL>ia.do_assert(<NUM_LIT:0> <= alpha_sample <= <NUM_LIT:1.0>)<EOL>matrix_nochange = np.array([<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]<EOL>], dtype=np.float32)<EOL>matrix_effect = np.array([<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:1>, -<NUM_LIT:4>, <NUM_LIT:1>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>]<EOL>], dtype=np.float32)<EOL>matrix = (<NUM_LIT:1>-alpha_sample) * matrix_nochange + alpha_sample * matrix_effect<EOL>return [matrix] * nb_channels<EOL><DEDENT>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return Convolve(create_matrices, name=name, deterministic=deterministic, random_state=random_state)<EOL>

Augmenter that detects all edges in images, marks them in
a black and white image and then overlays the result with the original
image.

dtype support::

    See ``imgaug.augmenters.convolutional.Convolve``.

Parameters
----------
alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Visibility of the sharpened image. At 0, only the original image is
    visible, at 1.0 only its sharpened version is visible.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list
          per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = EdgeDetect(alpha=(0.0, 1.0))

detects edges in an image  and overlays the result with a variable alpha
in the range ``0.0 <= a <= 1.0`` over the old image.


def DirectedEdgeDetect(alpha=<NUM_LIT:0>, direction=(<NUM_LIT:0.0>, <NUM_LIT:1.0>), name=None, deterministic=False, random_state=None):

alpha_param = iap.handle_continuous_param(alpha, "<STR_LIT>", value_range=(<NUM_LIT:0>, <NUM_LIT:1.0>), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>direction_param = iap.handle_continuous_param(direction, "<STR_LIT>", value_range=None, tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>def create_matrices(_image, nb_channels, random_state_func):<EOL><INDENT>alpha_sample = alpha_param.draw_sample(random_state=random_state_func)<EOL>ia.do_assert(<NUM_LIT:0> <= alpha_sample <= <NUM_LIT:1.0>)<EOL>direction_sample = direction_param.draw_sample(random_state=random_state_func)<EOL>deg = int(direction_sample * <NUM_LIT>) % <NUM_LIT><EOL>rad = np.deg2rad(deg)<EOL>x = np.cos(rad - <NUM_LIT:0.5>*np.pi)<EOL>y = np.sin(rad - <NUM_LIT:0.5>*np.pi)<EOL>direction_vector = np.array([x, y])<EOL>matrix_effect = np.array([<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]<EOL>], dtype=np.float32)<EOL>for x in [-<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>]:<EOL><INDENT>for y in [-<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>]:<EOL><INDENT>if (x, y) != (<NUM_LIT:0>, <NUM_LIT:0>):<EOL><INDENT>cell_vector = np.array([x, y])<EOL>distance_deg = np.rad2deg(ia.angle_between_vectors(cell_vector, direction_vector))<EOL>distance = distance_deg / <NUM_LIT><EOL>similarity = (<NUM_LIT:1> - distance)**<NUM_LIT:4><EOL>matrix_effect[y+<NUM_LIT:1>, x+<NUM_LIT:1>] = similarity<EOL><DEDENT><DEDENT><DEDENT>matrix_effect = matrix_effect / np.sum(matrix_effect)<EOL>matrix_effect = matrix_effect * (-<NUM_LIT:1>)<EOL>matrix_effect[<NUM_LIT:1>, <NUM_LIT:1>] = <NUM_LIT:1><EOL>matrix_nochange = np.array([<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]<EOL>], dtype=np.float32)<EOL>matrix = (<NUM_LIT:1>-alpha_sample) * matrix_nochange + alpha_sample * matrix_effect<EOL>return [matrix] * nb_channels<EOL><DEDENT>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return Convolve(create_matrices, name=name, deterministic=deterministic, random_state=random_state)<EOL>

Augmenter that detects edges that have certain directions and marks them
in a black and white image and then overlays the result with the original
image.

dtype support::

    See ``imgaug.augmenters.convolutional.Convolve``.

Parameters
----------
alpha : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Visibility of the sharpened image. At 0, only the original image is
    visible, at 1.0 only its sharpened version is visible.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list
          per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

direction : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Angle of edges to pronounce, where 0 represents 0 degrees and 1.0
    represents 360 degrees (both clockwise, starting at the top).
    Default value is ``(0.0, 1.0)``, i.e. pick a random angle per image.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list
          per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = DirectedEdgeDetect(alpha=1.0, direction=0)

turns input images into edge images in which edges are detected from
top side of the image (i.e. the top sides of horizontal edges are
added to the output).

>>> aug = DirectedEdgeDetect(alpha=1.0, direction=90/360)

same as before, but detecting edges from the right (right side of each
vertical edge).

>>> aug = DirectedEdgeDetect(alpha=1.0, direction=(0.0, 1.0))

same as before, but detecting edges from a variable direction (anything
between 0 and 1.0, i.e. 0 degrees and 360 degrees, starting from the
top and moving clockwise).

>>> aug = DirectedEdgeDetect(alpha=(0.0, 0.3), direction=0)

generates edge images (edges detected from the top) and overlays them
with the input images by a variable amount between 0 and 30 percent
(e.g. for 0.3 then ``0.7*old_image + 0.3*edge_image``).


return Fliplr(*args, **kwargs)<EOL>


return Flipud(*args, **kwargs)<EOL>


def AdditiveGaussianNoise(loc=<NUM_LIT:0>, scale=<NUM_LIT:0>, per_channel=False, name=None, deterministic=False, random_state=None):

loc2 = iap.handle_continuous_param(loc, "<STR_LIT>", value_range=None, tuple_to_uniform=True, list_to_choice=True)<EOL>scale2 = iap.handle_continuous_param(scale, "<STR_LIT>", value_range=(<NUM_LIT:0>, None), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return AddElementwise(iap.Normal(loc=loc2, scale=scale2), per_channel=per_channel, name=name,<EOL>deterministic=deterministic, random_state=random_state)<EOL>

Add gaussian noise (aka white noise) to images.

dtype support::

    See ``imgaug.augmenters.arithmetic.AddElementwise``.

Parameters
----------
loc : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Mean of the normal distribution that generates the noise.

        * If a number, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list per
          image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

scale : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Standard deviation of the normal distribution that generates the noise.
    Must be ``>= 0``. If 0 then only `loc` will be used.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list per
          image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

per_channel : bool or float, optional
    Whether to use the same noise value per pixel for all channels (False)
    or to sample a new value for each channel (True).
    If this value is a float ``p``, then for ``p`` percent of all images
    `per_channel` will be treated as True, otherwise as False.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = iaa.AdditiveGaussianNoise(scale=0.1*255)

adds gaussian noise from the distribution ``N(0, 0.1*255)`` to images.

>>> aug = iaa.AdditiveGaussianNoise(scale=(0, 0.1*255))

adds gaussian noise from the distribution ``N(0, s)`` to images,
where s is sampled per image from the range ``0 <= s <= 0.1*255``.

>>> aug = iaa.AdditiveGaussianNoise(scale=0.1*255, per_channel=True)

adds gaussian noise from the distribution ``N(0, 0.1*255)`` to images,
where the noise value is different per pixel *and* channel (e.g. a
different one for red, green and blue channels for the same pixel).

>>> aug = iaa.AdditiveGaussianNoise(scale=0.1*255, per_channel=0.5)

adds gaussian noise from the distribution ``N(0, 0.1*255)`` to images,
where the noise value is sometimes (50 percent of all cases) the same
per pixel for all channels and sometimes different (other 50 percent).


def AdditiveLaplaceNoise(loc=<NUM_LIT:0>, scale=<NUM_LIT:0>, per_channel=False, name=None, deterministic=False, random_state=None):

loc2 = iap.handle_continuous_param(loc, "<STR_LIT>", value_range=None, tuple_to_uniform=True, list_to_choice=True)<EOL>scale2 = iap.handle_continuous_param(scale, "<STR_LIT>", value_range=(<NUM_LIT:0>, None), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return AddElementwise(iap.Laplace(loc=loc2, scale=scale2), per_channel=per_channel, name=name,<EOL>deterministic=deterministic, random_state=random_state)<EOL>

Add laplace noise to images.

The laplace distribution is similar to the gaussian distribution, but has puts weight on the long tail.
Hence, this noise will add more outliers (very high/low values). It is somewhere between gaussian noise and
salt and pepper noise.

Values of around ``255 * 0.05`` for `scale` lead to visible noise (for uint8).
Values of around ``255 * 0.10`` for `scale` lead to very visible noise (for uint8).
It is recommended to usually set `per_channel` to True.

dtype support::

    See ``imgaug.augmenters.arithmetic.AddElementwise``.

Parameters
----------
loc : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Mean of the laplace distribution that generates the noise.

        * If a number, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list per
          image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

scale : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Standard deviation of the laplace distribution that generates the noise.
    Must be ``>= 0``. If 0 then only `loc` will be used.
    Recommended to be around ``255 * 0.05``.

        * If an int or float, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list per
          image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

per_channel : bool or float, optional
    Whether to use the same noise value per pixel for all channels (False)
    or to sample a new value for each channel (True).
    If this value is a float ``p``, then for ``p`` percent of all images
    `per_channel` will be treated as True, otherwise as False.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = iaa.AdditiveLaplaceNoise(scale=0.1*255)

Adds laplace noise from the distribution ``Laplace(0, 0.1*255)`` to images.

>>> aug = iaa.AdditiveLaplaceNoise(scale=(0, 0.1*255))

Adds laplace noise from the distribution ``Laplace(0, s)`` to images,
where s is sampled per image from the range ``0 <= s <= 0.1*255``.

>>> aug = iaa.AdditiveLaplaceNoise(scale=0.1*255, per_channel=True)

Adds laplace noise from the distribution ``Laplace(0, 0.1*255)`` to images,
where the noise value is different per pixel *and* channel (e.g. a
different one for red, green and blue channels for the same pixel).

>>> aug = iaa.AdditiveLaplaceNoise(scale=0.1*255, per_channel=0.5)

Adds laplace noise from the distribution ``Laplace(0, 0.1*255)`` to images,
where the noise value is sometimes (50 percent of all cases) the same
per pixel for all channels and sometimes different (other 50 percent).


def AdditivePoissonNoise(lam=<NUM_LIT:0>, per_channel=False, name=None, deterministic=False, random_state=None):

lam2 = iap.handle_continuous_param(lam, "<STR_LIT>", value_range=(<NUM_LIT:0>, None), tuple_to_uniform=True,<EOL>list_to_choice=True)<EOL>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return AddElementwise(iap.RandomSign(iap.Poisson(lam=lam2)), per_channel=per_channel, name=name,<EOL>deterministic=deterministic, random_state=random_state)<EOL>

Create an augmenter to add poisson noise to images.

Poisson noise is comparable to gaussian noise as in ``AdditiveGaussianNoise``, but the values are sampled from
a poisson distribution instead of a gaussian distribution. As poisson distributions produce only positive numbers,
the sign of the sampled values are here randomly flipped.

Values of around ``10.0`` for `lam` lead to visible noise (for uint8).
Values of around ``20.0`` for `lam` lead to very visible noise (for uint8).
It is recommended to usually set `per_channel` to True.

dtype support::

    See ``imgaug.augmenters.arithmetic.AddElementwise``.

Parameters
----------
lam : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional
    Lambda parameter of the poisson distribution. Recommended values are around ``0.0`` to ``10.0``.

        * If a number, exactly that value will be used.
        * If a tuple ``(a, b)``, a random value from the range ``a <= x <= b`` will
          be sampled per image.
        * If a list, then a random value will be sampled from that list per image.
        * If a StochasticParameter, a value will be sampled from the
          parameter per image.

per_channel : bool or float, optional
    Whether to use the same noise value per pixel for all channels (False)
    or to sample a new value for each channel (True).
    If this value is a float ``p``, then for ``p`` percent of all images
    `per_channel` will be treated as True, otherwise as False.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = iaa.AdditivePoissonNoise(lam=5.0)

Adds poisson noise sampled from ``Poisson(5.0)`` to images.

>>> aug = iaa.AdditivePoissonNoise(lam=(0.0, 10.0))

Adds poisson noise sampled from ``Poisson(x)`` to images, where ``x`` is randomly sampled per image from the
interval ``[0.0, 10.0]``.

>>> aug = iaa.AdditivePoissonNoise(lam=5.0, per_channel=True)

Adds poisson noise sampled from ``Poisson(5.0)`` to images,
where the values are different per pixel *and* channel (e.g. a
different one for red, green and blue channels for the same pixel).

>>> aug = iaa.AdditivePoissonNoise(lam=(0.0, 10.0), per_channel=True)

Adds poisson noise sampled from ``Poisson(x)`` to images,
with ``x`` being sampled from ``uniform(0.0, 10.0)`` per image, pixel and channel.
This is the *recommended* configuration.

>>> aug = iaa.AdditivePoissonNoise(lam=2, per_channel=0.5)

Adds poisson noise sampled from the distribution ``Poisson(2)`` to images,
where the values are sometimes (50 percent of all cases) the same
per pixel for all channels and sometimes different (other 50 percent).


def Dropout(p=<NUM_LIT:0>, per_channel=False, name=None, deterministic=False, random_state=None):

if ia.is_single_number(p):<EOL><INDENT>p2 = iap.Binomial(<NUM_LIT:1> - p)<EOL><DEDENT>elif ia.is_iterable(p):<EOL><INDENT>ia.do_assert(len(p) == <NUM_LIT:2>)<EOL>ia.do_assert(p[<NUM_LIT:0>] < p[<NUM_LIT:1>])<EOL>ia.do_assert(<NUM_LIT:0> <= p[<NUM_LIT:0>] <= <NUM_LIT:1.0>)<EOL>ia.do_assert(<NUM_LIT:0> <= p[<NUM_LIT:1>] <= <NUM_LIT:1.0>)<EOL>p2 = iap.Binomial(iap.Uniform(<NUM_LIT:1> - p[<NUM_LIT:1>], <NUM_LIT:1> - p[<NUM_LIT:0>]))<EOL><DEDENT>elif isinstance(p, iap.StochasticParameter):<EOL><INDENT>p2 = p<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % (type(p),))<EOL><DEDENT>if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return MultiplyElementwise(p2, per_channel=per_channel, name=name, deterministic=deterministic,<EOL>random_state=random_state)<EOL>

Augmenter that sets a certain fraction of pixels in images to zero.

dtype support::

    See ``imgaug.augmenters.arithmetic.MultiplyElementwise``.

Parameters
----------
p : float or tuple of float or imgaug.parameters.StochasticParameter, optional
    The probability of any pixel being dropped (i.e. set to zero).

        * If a float, then that value will be used for all images. A value
          of 1.0 would mean that all pixels will be dropped and 0.0 that
          no pixels would be dropped. A value of 0.05 corresponds to 5
          percent of all pixels dropped.
        * If a tuple ``(a, b)``, then a value p will be sampled from the
          range ``a <= p <= b`` per image and be used as the pixel's dropout
          probability.
        * If a StochasticParameter, then this parameter will be used to
          determine per pixel whether it should be dropped (sampled value
          of 0) or shouldn't (sampled value of 1).
          If you instead want to provide the probability as a stochastic
          parameter, you can usually do ``imgaug.parameters.Binomial(1-p)``
          to convert parameter `p` to a 0/1 representation.

per_channel : bool or float, optional
    Whether to use the same value (is dropped / is not dropped)
    for all channels of a pixel (False) or to sample a new value for each
    channel (True).
    If this value is a float p, then for p percent of all images
    `per_channel` will be treated as True, otherwise as False.

name : None or str, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

deterministic : bool, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

random_state : None or int or numpy.random.RandomState, optional
    See :func:`imgaug.augmenters.meta.Augmenter.__init__`.

Examples
--------
>>> aug = iaa.Dropout(0.02)

drops 2 percent of all pixels.

>>> aug = iaa.Dropout((0.0, 0.05))

drops in each image a random fraction of all pixels, where the fraction
is in the range ``0.0 <= x <= 0.05``.

>>> aug = iaa.Dropout(0.02, per_channel=True)

drops 2 percent of all pixels in a channel-wise fashion, i.e. it is unlikely
for any pixel to have all channels set to zero (black pixels).

>>> aug = iaa.Dropout(0.02, per_channel=0.5)

same as previous example, but the `per_channel` feature is only active
for 50 percent of all images.