return self.deepcopy(self.x + x, self.y + y)<EOL>

Move the keypoint around on an image.

Parameters
----------
x : number, optional
    Move by this value on the x axis.

y : number, optional
    Move by this value on the y axis.

Returns
-------
imgaug.Keypoint
    Keypoint object with new coordinates.


@staticmethod<EOL><INDENT>def from_distance_maps(distance_maps, inverted=False, if_not_found_coords={"<STR_LIT:x>": -<NUM_LIT:1>, "<STR_LIT:y>": -<NUM_LIT:1>}, threshold=None, <EOL>nb_channels=None):<DEDENT>

ia.do_assert(len(distance_maps.shape) == <NUM_LIT:3>)<EOL>height, width, nb_keypoints = distance_maps.shape<EOL>drop_if_not_found = False<EOL>if if_not_found_coords is None:<EOL><INDENT>drop_if_not_found = True<EOL>if_not_found_x = -<NUM_LIT:1><EOL>if_not_found_y = -<NUM_LIT:1><EOL><DEDENT>elif isinstance(if_not_found_coords, (tuple, list)):<EOL><INDENT>ia.do_assert(len(if_not_found_coords) == <NUM_LIT:2>)<EOL>if_not_found_x = if_not_found_coords[<NUM_LIT:0>]<EOL>if_not_found_y = if_not_found_coords[<NUM_LIT:1>]<EOL><DEDENT>elif isinstance(if_not_found_coords, dict):<EOL><INDENT>if_not_found_x = if_not_found_coords["<STR_LIT:x>"]<EOL>if_not_found_y = if_not_found_coords["<STR_LIT:y>"]<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % (<EOL>type(if_not_found_coords),))<EOL><DEDENT>keypoints = []<EOL>for i in sm.xrange(nb_keypoints):<EOL><INDENT>if inverted:<EOL><INDENT>hitidx_flat = np.argmax(distance_maps[..., i])<EOL><DEDENT>else:<EOL><INDENT>hitidx_flat = np.argmin(distance_maps[..., i])<EOL><DEDENT>hitidx_ndim = np.unravel_index(hitidx_flat, (height, width))<EOL>if not inverted and threshold is not None:<EOL><INDENT>found = (distance_maps[hitidx_ndim[<NUM_LIT:0>], hitidx_ndim[<NUM_LIT:1>], i] < threshold)<EOL><DEDENT>elif inverted and threshold is not None:<EOL><INDENT>found = (distance_maps[hitidx_ndim[<NUM_LIT:0>], hitidx_ndim[<NUM_LIT:1>], i] >= threshold)<EOL><DEDENT>else:<EOL><INDENT>found = True<EOL><DEDENT>if found:<EOL><INDENT>keypoints.append(Keypoint(x=hitidx_ndim[<NUM_LIT:1>], y=hitidx_ndim[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>if drop_if_not_found:<EOL><INDENT>pass  <EOL><DEDENT>else:<EOL><INDENT>keypoints.append(Keypoint(x=if_not_found_x, y=if_not_found_y))<EOL><DEDENT><DEDENT><DEDENT>out_shape = (height, width)<EOL>if nb_channels is not None:<EOL><INDENT>out_shape += (nb_channels,)<EOL><DEDENT>return KeypointsOnImage(keypoints, shape=out_shape)<EOL>

Converts maps generated by ``to_distance_maps()`` back to a KeypointsOnImage object.

Parameters
----------
distance_maps : (H,W,N) ndarray
    The distance maps. N is the number of keypoints.

inverted : bool, optional
    Whether the given distance maps were generated in inverted or normal mode.

if_not_found_coords : tuple or list or dict or None, optional
    Coordinates to use for keypoints that cannot be found in ``distance_maps``.
    If this is a list/tuple, it must have two integer values.
    If it is a dictionary, it must have the keys ``x`` and ``y``, with each
    containing one integer value.
    If this is None, then the keypoint will not be added to the final
    KeypointsOnImage object.

threshold : float, optional
    The search for keypoints works by searching for the argmin (non-inverted) or
    argmax (inverted) in each channel. This parameters contains the maximum (non-inverted)
    or minimum (inverted) value to accept in order to view a hit as a keypoint.
    Use None to use no min/max.

nb_channels : None or int, optional
    Number of channels of the image on which the keypoints are placed.
    Some keypoint augmenters require that information.
    If set to None, the keypoint's shape will be set
    to ``(height, width)``, otherwise ``(height, width, nb_channels)``.

Returns
-------
imgaug.KeypointsOnImage
    The extracted keypoints.


ia.do_assert(len(self.keypoints) > <NUM_LIT:0>)<EOL>height, width = self.shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>distance_maps = np.zeros((height, width, len(self.keypoints)), dtype=np.float32)<EOL>yy = np.arange(<NUM_LIT:0>, height)<EOL>xx = np.arange(<NUM_LIT:0>, width)<EOL>grid_xx, grid_yy = np.meshgrid(xx, yy)<EOL>for i, keypoint in enumerate(self.keypoints):<EOL><INDENT>y, x = keypoint.y, keypoint.x<EOL>distance_maps[:, :, i] = (grid_xx - x) ** <NUM_LIT:2> + (grid_yy - y) ** <NUM_LIT:2><EOL><DEDENT>distance_maps = np.sqrt(distance_maps)<EOL>if inverted:<EOL><INDENT>return <NUM_LIT:1>/(distance_maps+<NUM_LIT:1>)<EOL><DEDENT>return distance_maps<EOL>

Generates a ``(H,W,K)`` output containing ``K`` distance maps for ``K`` keypoints.

The k-th distance map contains at every location ``(y, x)`` the euclidean distance to the k-th keypoint.

This function can be used as a helper when augmenting keypoints with a method that only supports
the augmentation of images.

Parameters
-------
inverted : bool, optional
    If True, inverted distance maps are returned where each distance value d is replaced
    by ``d/(d+1)``, i.e. the distance maps have values in the range ``(0.0, 1.0]`` with 1.0
    denoting exactly the position of the respective keypoint.

Returns
-------
distance_maps : (H,W,K) ndarray
    A ``float32`` array containing ``K`` distance maps for ``K`` keypoints. Each location
    ``(y, x, k)`` in the array denotes the euclidean distance at ``(y, x)`` to the ``k``-th keypoint.
    In inverted mode the distance ``d`` is replaced by ``d/(d+1)``. The height and width
    of the array match the height and width in ``KeypointsOnImage.shape``.


def draw_lines_on_image(self, image, color=(<NUM_LIT:0>, <NUM_LIT:255>, <NUM_LIT:0>),<EOL>alpha=<NUM_LIT:1.0>, size=<NUM_LIT:3>,<EOL>antialiased=True,<EOL>raise_if_out_of_image=False):

from .. import dtypes as iadt<EOL>from ..augmenters import blend as blendlib<EOL>image_was_empty = False<EOL>if isinstance(image, tuple):<EOL><INDENT>image_was_empty = True<EOL>image = np.zeros(image, dtype=np.uint8)<EOL><DEDENT>assert image.ndim in [<NUM_LIT:2>, <NUM_LIT:3>], (<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>") % (image.shape,))<EOL>if len(self.coords) <= <NUM_LIT:1> or alpha < <NUM_LIT:0> + <NUM_LIT> or size < <NUM_LIT:1>:<EOL><INDENT>return np.copy(image)<EOL><DEDENT>if raise_if_out_of_imageand self.is_out_of_image(image, partly=False, fully=True):<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (<EOL>self.__str__(), image.shape))<EOL><DEDENT>if image.ndim == <NUM_LIT:2>:<EOL><INDENT>assert ia.is_single_number(color), (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (str(color),))<EOL>color = [color]<EOL><DEDENT>elif image.ndim == <NUM_LIT:3> and ia.is_single_number(color):<EOL><INDENT>color = [color] * image.shape[-<NUM_LIT:1>]<EOL><DEDENT>image = image.astype(np.float32)<EOL>height, width = image.shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>lines = []<EOL>for line_start, line_end in zip(self.coords[:-<NUM_LIT:1>], self.coords[<NUM_LIT:1>:]):<EOL><INDENT>lines.append((line_start[<NUM_LIT:1>], line_start[<NUM_LIT:0>],<EOL>line_end[<NUM_LIT:1>], line_end[<NUM_LIT:0>]))<EOL><DEDENT>lines = np.round(np.float32(lines)).astype(np.int32)<EOL>color = np.float32(color)<EOL>heatmap = np.zeros(image.shape[<NUM_LIT:0>:<NUM_LIT:2>], dtype=np.float32)<EOL>for line in lines:<EOL><INDENT>if antialiased:<EOL><INDENT>rr, cc, val = skimage.draw.line_aa(*line)<EOL><DEDENT>else:<EOL><INDENT>rr, cc = skimage.draw.line(*line)<EOL>val = <NUM_LIT:1.0><EOL><DEDENT>rr_mask = np.logical_and(<NUM_LIT:0> <= rr, rr < height)<EOL>cc_mask = np.logical_and(<NUM_LIT:0> <= cc, cc < width)<EOL>mask = np.logical_and(rr_mask, cc_mask)<EOL>if np.any(mask):<EOL><INDENT>rr = rr[mask]<EOL>cc = cc[mask]<EOL>val = val[mask] if not ia.is_single_number(val) else val<EOL>heatmap[rr, cc] = val * alpha<EOL><DEDENT><DEDENT>if size > <NUM_LIT:1>:<EOL><INDENT>kernel = np.ones((size, size), dtype=np.uint8)<EOL>heatmap = cv2.dilate(heatmap, kernel)<EOL><DEDENT>if image_was_empty:<EOL><INDENT>image_blend = image + heatmap * color<EOL><DEDENT>else:<EOL><INDENT>image_color_shape = image.shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>if image.ndim == <NUM_LIT:3>:<EOL><INDENT>image_color_shape = image_color_shape + (<NUM_LIT:1>,)<EOL><DEDENT>image_color = np.tile(color, image_color_shape)<EOL>image_blend = blendlib.blend_alpha(image_color, image, heatmap)<EOL><DEDENT>image_blend = iadt.restore_dtypes_(image_blend, np.uint8)<EOL>return image_blend<EOL>

Draw the line segments of the line string on a given image.

Parameters
----------
image : ndarray or tuple of int
    The image onto which to draw.
    Expected to be ``uint8`` and of shape ``(H, W, C)`` with ``C``
    usually being ``3`` (other values are not tested).
    If a tuple, expected to be ``(H, W, C)`` and will lead to a new
    ``uint8`` array of zeros being created.

color : int or iterable of int
    Color to use as RGB, i.e. three values.

alpha : float, optional
    Opacity of the line string. Higher values denote a more visible
    line string.

size : int, optional
    Thickness of the line segments.

antialiased : bool, optional
    Whether to draw the line with anti-aliasing activated.

raise_if_out_of_image : bool, optional
    Whether to raise an error if the line string is fully
    outside of the image. If set to False, no error will be raised and
    only the parts inside the image will be drawn.

Returns
-------
ndarray
    `image` with line drawn on it.


return np.round(self.yy).astype(np.int32)<EOL>

Get an array of discrete y-coordinates of all points.


def coords_almost_equals(self, other, max_distance=<NUM_LIT>, points_per_edge=<NUM_LIT:8>):

if isinstance(other, LineString):<EOL><INDENT>pass<EOL><DEDENT>elif isinstance(other, tuple):<EOL><INDENT>other = LineString([other])<EOL><DEDENT>else:<EOL><INDENT>other = LineString(other)<EOL><DEDENT>if len(self.coords) == <NUM_LIT:0> and len(other.coords) == <NUM_LIT:0>:<EOL><INDENT>return True<EOL><DEDENT>elif <NUM_LIT:0> in [len(self.coords), len(other.coords)]:<EOL><INDENT>return False<EOL><DEDENT>self_subd = self.subdivide(points_per_edge)<EOL>other_subd = other.subdivide(points_per_edge)<EOL>dist_self2other = self_subd.compute_pointwise_distances(other_subd)<EOL>dist_other2self = other_subd.compute_pointwise_distances(self_subd)<EOL>dist = max(np.max(dist_self2other), np.max(dist_other2self))<EOL>return  dist < max_distance<EOL>

Compare this and another LineString's coordinates.

This is an approximate method based on pointwise distances and can
in rare corner cases produce wrong outputs.

Parameters
----------
other : imgaug.augmentables.lines.LineString \
        or tuple of number \
        or ndarray \
        or list of ndarray \
        or list of tuple of number
    The other line string or its coordinates.

max_distance : float
    Max distance of any point from the other line string before
    the two line strings are evaluated to be unequal.

points_per_edge : int, optional
    How many points to interpolate on each edge.

Returns
-------
bool
    Whether the two LineString's coordinates are almost identical,
    i.e. the max distance is below the threshold.
    If both have no coordinates, ``True`` is returned.
    If only one has no coordinates, ``False`` is returned.
    Beyond that, the number of points is not evaluated.


def almost_equals(self, other, max_distance=<NUM_LIT>, points_per_edge=<NUM_LIT:8>):

if self.label != other.label:<EOL><INDENT>return False<EOL><DEDENT>return self.coords_almost_equals(<EOL>other, max_distance=max_distance, points_per_edge=points_per_edge)<EOL>

Compare this and another LineString.

Parameters
----------
other: imgaug.augmentables.lines.LineString
    The other line string. Must be a LineString instance, not just
    its coordinates.

max_distance : float, optional
    See :func:`imgaug.augmentables.lines.LineString.coords_almost_equals`.

points_per_edge : int, optional
    See :func:`imgaug.augmentables.lines.LineString.coords_almost_equals`.

Returns
-------
bool
    ``True`` if the coordinates are almost equal according to
    :func:`imgaug.augmentables.lines.LineString.coords_almost_equals`
    and additionally the labels are identical. Otherwise ``False``.


lss_cut = [ls_clipped<EOL>for ls in self.line_strings<EOL>for ls_clipped in ls.clip_out_of_image(self.shape)]<EOL>return LineStringsOnImage(lss_cut, shape=self.shape)<EOL>

Clip off all parts of the line strings that are outside of the image.

Returns
-------
imgaug.augmentables.lines.LineStringsOnImage
    Line strings, clipped to fall within the image dimensions.


def contains(self, other, max_distance=<NUM_LIT>):

return self.compute_distance(other, default=np.inf) < max_distance<EOL>

Estimate whether the bounding box contains a point.

Parameters
----------
other : tuple of number or imgaug.augmentables.kps.Keypoint
    Point to check for.

max_distance : float
    Maximum allowed euclidean distance between the point and the
    closest point on the line. If the threshold is exceeded, the point
    is not considered to be contained in the line.

Returns
-------
bool
    True if the point is contained in the line string, False otherwise.
    It is contained if its distance to the line or any of its points
    is below a threshold.


def is_fully_within_image(self, image, default=False):

if len(self.coords) == <NUM_LIT:0>:<EOL><INDENT>return default<EOL><DEDENT>return np.all(self.get_pointwise_inside_image_mask(image))<EOL>

Estimate whether the line string is fully inside the image area.

Parameters
----------
image : ndarray or tuple of int
    Either an image with shape ``(H,W,[C])`` or a tuple denoting
    such an image shape.

default
    Default value to return if the line string contains no points.

Returns
-------
bool
    True if the line string is fully inside the image area.
    False otherwise.


def deepcopy(self, coords=None, label=None):

return LineString(<EOL>coords=np.copy(self.coords) if coords is None else coords,<EOL>label=copylib.deepcopy(self.label) if label is None else label)<EOL>

Create a deep copy of the BoundingBox object.

Parameters
----------
coords : None or iterable of tuple of number or ndarray
    If not ``None``, then the coords of the copied object will be set
    to this value.

label : None or str
    If not ``None``, then the label of the copied object will be set to
    this value.

Returns
-------
imgaug.augmentables.lines.LineString
    Deep copy.


def compute_pointwise_distances(self, other, default=None):

import shapely.geometry<EOL>from .kps import Keypoint<EOL>if isinstance(other, Keypoint):<EOL><INDENT>other = shapely.geometry.Point((other.x, other.y))<EOL><DEDENT>elif isinstance(other, LineString):<EOL><INDENT>if len(other.coords) == <NUM_LIT:0>:<EOL><INDENT>return default<EOL><DEDENT>elif len(other.coords) == <NUM_LIT:1>:<EOL><INDENT>other = shapely.geometry.Point(other.coords[<NUM_LIT:0>, :])<EOL><DEDENT>else:<EOL><INDENT>other = shapely.geometry.LineString(other.coords)<EOL><DEDENT><DEDENT>elif isinstance(other, tuple):<EOL><INDENT>assert len(other) == <NUM_LIT:2><EOL>other = shapely.geometry.Point(other)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>") % (type(other),))<EOL><DEDENT>return [shapely.geometry.Point(point).distance(other)<EOL>for point in self.coords]<EOL>

Compute the minimal distance between each point on self and other.

Parameters
----------
other : tuple of number \
        or imgaug.augmentables.kps.Keypoint \
        or imgaug.augmentables.LineString
    Other object to which to compute the distances.

default
    Value to return if `other` contains no points.

Returns
-------
list of float
    Distances to `other` or `default` if not distance could be computed.


import shapely.geometry<EOL>geom = _convert_var_to_shapely_geometry(other)<EOL>result = []<EOL>for p_start, p_end in zip(self.coords[:-<NUM_LIT:1>], self.coords[<NUM_LIT:1>:]):<EOL><INDENT>ls = shapely.geometry.LineString([p_start, p_end])<EOL>intersections = ls.intersection(geom)<EOL>intersections = list(_flatten_shapely_collection(intersections))<EOL>intersections_points = []<EOL>for inter in intersections:<EOL><INDENT>if isinstance(inter, shapely.geometry.linestring.LineString):<EOL><INDENT>inter_start = (inter.coords[<NUM_LIT:0>][<NUM_LIT:0>], inter.coords[<NUM_LIT:0>][<NUM_LIT:1>])<EOL>inter_end = (inter.coords[-<NUM_LIT:1>][<NUM_LIT:0>], inter.coords[-<NUM_LIT:1>][<NUM_LIT:1>])<EOL>intersections_points.extend([inter_start, inter_end])<EOL><DEDENT>else:<EOL><INDENT>assert isinstance(inter, shapely.geometry.point.Point), (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (type(inter),))<EOL>intersections_points.append((inter.x, inter.y))<EOL><DEDENT><DEDENT>inter_sorted = sorted(<EOL>intersections_points,<EOL>key=lambda p: np.linalg.norm(np.float32(p) - p_start)<EOL>)<EOL>result.append(inter_sorted)<EOL><DEDENT>return result<EOL>

Find all intersection points between the line string and `other`.

Parameters
----------
other : tuple of number or list of tuple of number or \
        list of LineString or LineString
    The other geometry to use during intersection tests.

Returns
-------
list of list of tuple of number
    All intersection points. One list per pair of consecutive start
    and end point, i.e. `N-1` lists of `N` points. Each list may
    be empty or may contain multiple points.


<EOL>from imgaug.augmentables.kps import Keypoint<EOL>return [Keypoint(x=x, y=y) for (x, y) in self.coords]<EOL>

Convert the line string points to keypoints.

Returns
-------
list of imgaug.augmentables.kps.Keypoint
    Points of the line string as keypoints.


def compute_distance(self, other, default=None):

<EOL>distances = self.compute_pointwise_distances(other, default=[])<EOL>if len(distances) == <NUM_LIT:0>:<EOL><INDENT>return default<EOL><DEDENT>return min(distances)<EOL>

Compute the minimal distance between the line string and `other`.

Parameters
----------
other : tuple of number \
        or imgaug.augmentables.kps.Keypoint \
        or imgaug.augmentables.LineString
    Other object to which to compute the distance.

default
    Value to return if this line string or `other` contain no points.

Returns
-------
float
    Distance to `other` or `default` if not distance could be computed.


def remove_out_of_image(self, fully=True, partly=False):

lss_clean = [ls for ls in self.line_strings<EOL>if not ls.is_out_of_image(<EOL>self.shape, fully=fully, partly=partly)]<EOL>return LineStringsOnImage(lss_clean, shape=self.shape)<EOL>

Remove all line strings that are fully/partially outside of the image.

Parameters
----------
fully : bool, optional
    Whether to remove line strings that are fully outside of the image.

partly : bool, optional
    Whether to remove line strings that are partially outside of the
    image.

Returns
-------
imgaug.augmentables.lines.LineStringsOnImage
    Reduced set of line strings, with those that were fully/partially
    outside of the image removed.


def draw_points_on_image(self, image, color=(<NUM_LIT:0>, <NUM_LIT>, <NUM_LIT:0>),<EOL>alpha=<NUM_LIT:1.0>, size=<NUM_LIT:3>,<EOL>copy=True, raise_if_out_of_image=False):

from .kps import KeypointsOnImage<EOL>kpsoi = KeypointsOnImage.from_xy_array(self.coords, shape=image.shape)<EOL>image = kpsoi.draw_on_image(<EOL>image, color=color, alpha=alpha,<EOL>size=size, copy=copy,<EOL>raise_if_out_of_image=raise_if_out_of_image)<EOL>return image<EOL>

Draw the points of the line string on a given image.

Parameters
----------
image : ndarray or tuple of int
    The image onto which to draw.
    Expected to be ``uint8`` and of shape ``(H, W, C)`` with ``C``
    usually being ``3`` (other values are not tested).
    If a tuple, expected to be ``(H, W, C)`` and will lead to a new
    ``uint8`` array of zeros being created.

color : iterable of int
    Color to use as RGB, i.e. three values.

alpha : float, optional
    Opacity of the line string points. Higher values denote a more
    visible points.

size : int, optional
    Size of the points in pixels.

copy : bool, optional
    Whether it is allowed to draw directly in the input
    array (``False``) or it has to be copied (``True``).
    The routine may still have to copy, even if ``copy=False`` was
    used. Always use the return value.

raise_if_out_of_image : bool, optional
    Whether to raise an error if the line string is fully
    outside of the image. If set to False, no error will be raised and
    only the parts inside the image will be drawn.

Returns
-------
ndarray
    Float array of shape `image_shape` (no channel axis) with drawn
    line string points. All values are in the interval ``[0.0, 1.0]``.


if len(self.coords) == <NUM_LIT:0>:<EOL><INDENT>return np.zeros((<NUM_LIT:0>,), dtype=bool)<EOL><DEDENT>shape = normalize_shape(image)<EOL>height, width = shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>x_within = np.logical_and(<NUM_LIT:0> <= self.xx, self.xx < width)<EOL>y_within = np.logical_and(<NUM_LIT:0> <= self.yy, self.yy < height)<EOL>return np.logical_and(x_within, y_within)<EOL>

Get for each point whether it is inside of the given image plane.

Parameters
----------
image : ndarray or tuple of int
    Either an image with shape ``(H,W,[C])`` or a tuple denoting
    such an image shape.

Returns
-------
ndarray
    Boolean array with one value per point indicating whether it is
    inside of the provided image plane (``True``) or not (``False``).


def deepcopy(self, line_strings=None, shape=None):

lss = self.line_strings if line_strings is None else line_strings<EOL>shape = self.shape if shape is None else shape<EOL>return LineStringsOnImage(<EOL>line_strings=[ls.deepcopy() for ls in lss],<EOL>shape=tuple(shape))<EOL>

Create a deep copy of the LineStringsOnImage object.

Parameters
----------
line_strings : None \
               or list of imgaug.augmentables.lines.LineString, optional
    List of line strings on the image.
    If not ``None``, then the ``line_strings`` attribute of the copied
    object will be set to this value.

shape : None or tuple of int or ndarray, optional
    The shape of the image on which the objects are placed.
    Either an image with shape ``(H,W,[C])`` or a tuple denoting
    such an image shape.
    If not ``None``, then the ``shape`` attribute of the copied object
    will be set to this value.

Returns
-------
imgaug.augmentables.lines.LineStringsOnImage
    Deep copy.


if len(self.coords) <= <NUM_LIT:1> or points_per_edge < <NUM_LIT:1>:<EOL><INDENT>return self.deepcopy()<EOL><DEDENT>coords = interpolate_points(self.coords, nb_steps=points_per_edge,<EOL>closed=False)<EOL>return self.deepcopy(coords=coords)<EOL>

Adds ``N`` interpolated points with uniform spacing to each edge.

For each edge between points ``A`` and ``B`` this adds points
at ``A + (i/(1+N)) * (B - A)``, where ``i`` is the index of the added
point and ``N`` is the number of points to add per edge.

Calling this method two times will split each edge at its center
and then again split each newly created edge at their center.
It is equivalent to calling `subdivide(3)`.

Parameters
----------
points_per_edge : int
    Number of points to interpolate on each edge.

Returns
-------
LineString
    Line string with subdivided edges.


shape = normalize_shape(image)<EOL>if shape[<NUM_LIT:0>:<NUM_LIT:2>] == self.shape[<NUM_LIT:0>:<NUM_LIT:2>]:<EOL><INDENT>return self.deepcopy()<EOL><DEDENT>line_strings = [ls.project(self.shape, shape)<EOL>for ls in self.line_strings]<EOL>return self.deepcopy(line_strings=line_strings, shape=shape)<EOL>

Project bounding boxes from one image to a new one.

Parameters
----------
image : ndarray or tuple of int
    The new image onto which to project.
    Either an image with shape ``(H,W,[C])`` or a tuple denoting
    such an image shape.

Returns
-------
line_strings : imgaug.augmentables.lines.LineStrings
    Object containing all projected line strings.


def is_out_of_image(self, image, fully=True, partly=False, default=True):

if len(self.coords) == <NUM_LIT:0>:<EOL><INDENT>return default<EOL><DEDENT>if self.is_fully_within_image(image):<EOL><INDENT>return False<EOL><DEDENT>elif self.is_partly_within_image(image):<EOL><INDENT>return partly<EOL><DEDENT>else:<EOL><INDENT>return fully<EOL><DEDENT>

Estimate whether the line is partially/fully outside of the image area.

Parameters
----------
image : ndarray or tuple of int
    Either an image with shape ``(H,W,[C])`` or a tuple denoting
    such an image shape.

fully : bool, optional
    Whether to return True if the bounding box is fully outside fo the
    image area.

partly : bool, optional
    Whether to return True if the bounding box is at least partially
    outside fo the image area.

default
    Default value to return if the line string contains no points.

Returns
-------
bool
    `default` if the line string has no points.
    True if the line string is partially/fully outside of the image
    area, depending on defined parameters.
    False otherwise.


def copy(self, coords=None, label=None):

return LineString(coords=self.coords if coords is None else coords,<EOL>label=self.label if label is None else label)<EOL>

Create a shallow copy of the LineString object.

Parameters
----------
coords : None or iterable of tuple of number or ndarray
    If not ``None``, then the coords of the copied object will be set
    to this value.

label : None or str
    If not ``None``, then the label of the copied object will be set to
    this value.

Returns
-------
imgaug.augmentables.lines.LineString
    Shallow copy.


def shift(self, top=None, right=None, bottom=None, left=None):

lss_new = [ls.shift(top=top, right=right, bottom=bottom, left=left)<EOL>for ls in self.line_strings]<EOL>return LineStringsOnImage(lss_new, shape=self.shape)<EOL>

Shift/move the line strings from one or more image sides.

Parameters
----------
top : None or int, optional
    Amount of pixels by which to shift all bounding boxes from the
    top.

right : None or int, optional
    Amount of pixels by which to shift all bounding boxes from the
    right.

bottom : None or int, optional
    Amount of pixels by which to shift all bounding boxes from the
    bottom.

left : None or int, optional
    Amount of pixels by which to shift all bounding boxes from the
    left.

Returns
-------
imgaug.augmentables.lines.LineStringsOnImage
    Shifted line strings.


if len(self.coords) <= <NUM_LIT:1>:<EOL><INDENT>return np.zeros((<NUM_LIT:0>,), dtype=np.float32)<EOL><DEDENT>return np.sqrt(<EOL>np.sum(<EOL>(self.coords[:-<NUM_LIT:1>, :] - self.coords[<NUM_LIT:1>:, :]) ** <NUM_LIT:2>,<EOL>axis=<NUM_LIT:1><EOL>)<EOL>)<EOL>

Get the euclidean distance between each two consecutive points.

Returns
-------
ndarray
    Euclidean distances between point pairs.
    Same order as in `coords`. For ``N`` points, ``N-1`` distances
    are returned.


return self.coords[:, <NUM_LIT:0>]<EOL>

Get an array of x-coordinates of all points of the line string.


if not isinstance(other, LineString):<EOL><INDENT>other = LineString(other)<EOL><DEDENT>return self.deepcopy(<EOL>coords=np.concatenate([self.coords, other.coords], axis=<NUM_LIT:0>))<EOL>

Concatenate this line string with another one.

This will add a line segment between the end point of this line string
and the start point of `other`.

Parameters
----------
other : imgaug.augmentables.lines.LineString or ndarray \
        or iterable of tuple of number
    The points to add to this line string.

Returns
-------
imgaug.augmentables.lines.LineString
    New line string with concatenated points.
    The `label` of this line string will be kept.


top = top if top is not None else <NUM_LIT:0><EOL>right = right if right is not None else <NUM_LIT:0><EOL>bottom = bottom if bottom is not None else <NUM_LIT:0><EOL>left = left if left is not None else <NUM_LIT:0><EOL>coords = np.copy(self.coords)<EOL>coords[:, <NUM_LIT:0>] += left - right<EOL>coords[:, <NUM_LIT:1>] += top - bottom<EOL>return self.copy(coords=coords)<EOL>

Shift/move the line string from one or more image sides.

Parameters
----------
top : None or int, optional
    Amount of pixels by which to shift the bounding box from the
    top.

right : None or int, optional
    Amount of pixels by which to shift the bounding box from the
    right.

bottom : None or int, optional
    Amount of pixels by which to shift the bounding box from the
    bottom.

left : None or int, optional
    Amount of pixels by which to shift the bounding box from the
    left.

Returns
-------
result : imgaug.augmentables.lines.LineString
    Shifted line string.


def draw_on_image(self, image, color=(<NUM_LIT:0>, <NUM_LIT:255>, <NUM_LIT:0>), alpha=<NUM_LIT:1.0>, size=<NUM_LIT:1>,<EOL>copy=True, raise_if_out_of_image=False, thickness=None):

image = np.copy(image) if copy else image<EOL>for bb in self.bounding_boxes:<EOL><INDENT>image = bb.draw_on_image(<EOL>image,<EOL>color=color,<EOL>alpha=alpha,<EOL>size=size,<EOL>copy=False,<EOL>raise_if_out_of_image=raise_if_out_of_image,<EOL>thickness=thickness<EOL>)<EOL><DEDENT>return image<EOL>

Draw all bounding boxes onto a given image.

Parameters
----------
image : (H,W,3) ndarray
    The image onto which to draw the bounding boxes.
    This image should usually have the same shape as
    set in BoundingBoxesOnImage.shape.

color : int or list of int or tuple of int or (3,) ndarray, optional
    The RGB color of all bounding boxes. If a single int ``C``, then
    that is equivalent to ``(C,C,C)``.

alpha : float, optional
    Alpha/transparency of the bounding box.

size : int, optional
    Thickness in pixels.

copy : bool, optional
    Whether to copy the image before drawing the bounding boxes.

raise_if_out_of_image : bool, optional
    Whether to raise an exception if any bounding box is outside of the
    image.

thickness : None or int, optional
    Deprecated.

Returns
-------
image : (H,W,3) ndarray
    Image with drawn bounding boxes.


inters = self.intersection(other)<EOL>if inters is None:<EOL><INDENT>return <NUM_LIT:0.0><EOL><DEDENT>else:<EOL><INDENT>area_union = self.area + other.area - inters.area<EOL>return inters.area / area_union if area_union > <NUM_LIT:0> else <NUM_LIT:0.0><EOL><DEDENT>

Compute the IoU of this bounding box with another one.

IoU is the intersection over union, defined as::

    ``area(intersection(A, B)) / area(union(A, B))``
    ``= area(intersection(A, B)) / (area(A) + area(B) - area(intersection(A, B)))``

Parameters
----------
other : imgaug.BoundingBox
    Other bounding box with which to compare.

Returns
-------
float
    IoU between the two bounding boxes.


if isinstance(other, tuple):<EOL><INDENT>x, y = other<EOL><DEDENT>else:<EOL><INDENT>x, y = other.x, other.y<EOL><DEDENT>return self.x1 <= x <= self.x2 and self.y1 <= y <= self.y2<EOL>

Estimate whether the bounding box contains a point.

Parameters
----------
other : tuple of number or imgaug.Keypoint
    Point to check for.

Returns
-------
bool
    True if the point is contained in the bounding box, False otherwise.


return int(np.round(self.x2))<EOL>

Return the x-coordinate of the bottom left corner as an integer.

Returns
-------
int
    X-coordinate of the bottom left corner, rounded to the closest integer.


return self.y1 + self.height/<NUM_LIT:2><EOL>

Estimate the y-coordinate of the center point of the bounding box.

Returns
-------
number
    Y-coordinate of the center point of the bounding box.


shape = normalize_shape(image)<EOL>height, width = shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>eps = np.finfo(np.float32).eps<EOL>img_bb = BoundingBox(x1=<NUM_LIT:0>, x2=width-eps, y1=<NUM_LIT:0>, y2=height-eps)<EOL>return self.intersection(img_bb) is not None<EOL>

Estimate whether the bounding box is at least partially inside the image area.

Parameters
----------
image : (H,W,...) ndarray or tuple of int
    Image dimensions to use.
    If an ndarray, its shape will be used.
    If a tuple, it is assumed to represent the image shape
    and must contain at least two integers.

Returns
-------
bool
    True if the bounding box is at least partially inside the image area. False otherwise.


return self.shape[<NUM_LIT:0>]<EOL>

Get the height of the image on which the bounding boxes fall.

Returns
-------
int
    Image height.


return self.y2 - self.y1<EOL>

Estimate the height of the bounding box.

Returns
-------
number
    Height of the bounding box.


return self.shape[<NUM_LIT:1>]<EOL>

Get the width of the image on which the bounding boxes fall.

Returns
-------
int
    Image width.


bbs_clean = [bb for bb in self.bounding_boxes<EOL>if not bb.is_out_of_image(self.shape, fully=fully, partly=partly)]<EOL>return BoundingBoxesOnImage(bbs_clean, shape=self.shape)<EOL>

Remove all bounding boxes that are fully or partially outside of the image.

Parameters
----------
fully : bool, optional
    Whether to remove bounding boxes that are fully outside of the image.

partly : bool, optional
    Whether to remove bounding boxes that are partially outside of the image.

Returns
-------
imgaug.BoundingBoxesOnImage
    Reduced set of bounding boxes, with those that were fully/partially outside of
    the image removed.


<EOL>bbs = [bb.deepcopy() for bb in self.bounding_boxes]<EOL>return BoundingBoxesOnImage(bbs, tuple(self.shape))<EOL>

Create a deep copy of the BoundingBoxesOnImage object.

Returns
-------
imgaug.BoundingBoxesOnImage
    Deep copy.


def intersection(self, other, default=None):

x1_i = max(self.x1, other.x1)<EOL>y1_i = max(self.y1, other.y1)<EOL>x2_i = min(self.x2, other.x2)<EOL>y2_i = min(self.y2, other.y2)<EOL>if x1_i > x2_i or y1_i > y2_i:<EOL><INDENT>return default<EOL><DEDENT>else:<EOL><INDENT>return BoundingBox(x1=x1_i, y1=y1_i, x2=x2_i, y2=y2_i)<EOL><DEDENT>

Compute the intersection bounding box of this bounding box and another one.

Note that in extreme cases, the intersection can be a single point, meaning that the intersection bounding box
will exist, but then also has a height and width of zero.

Parameters
----------
other : imgaug.BoundingBox
    Other bounding box with which to generate the intersection.

default : any, optional
    Default value to return if there is no intersection.

Returns
-------
imgaug.BoundingBox or any
    Intersection bounding box of the two bounding boxes if there is an intersection.
    If there is no intersection, the default value will be returned, which can by anything.


<EOL>from imgaug.augmentables.kps import Keypoint<EOL>return [<EOL>Keypoint(x=self.x1, y=self.y1),<EOL>Keypoint(x=self.x2, y=self.y1),<EOL>Keypoint(x=self.x2, y=self.y2),<EOL>Keypoint(x=self.x1, y=self.y2)<EOL>]<EOL>

Convert the corners of the bounding box to keypoints (clockwise, starting at top left).

Returns
-------
list of imgaug.Keypoint
    Corners of the bounding box as keypoints.


def deepcopy(self, x1=None, y1=None, x2=None, y2=None, label=None):

return self.copy(x1=x1, y1=y1, x2=x2, y2=y2, label=label)<EOL>

Create a deep copy of the BoundingBox object.

Parameters
----------
x1 : None or number
    If not None, then the x1 coordinate of the copied object will be set to this value.

y1 : None or number
    If not None, then the y1 coordinate of the copied object will be set to this value.

x2 : None or number
    If not None, then the x2 coordinate of the copied object will be set to this value.

y2 : None or number
    If not None, then the y2 coordinate of the copied object will be set to this value.

label : None or string
    If not None, then the label of the copied object will be set to this value.

Returns
-------
imgaug.BoundingBox
    Deep copy.


return copy.copy(self)<EOL>

Create a shallow copy of the BoundingBoxesOnImage object.

Returns
-------
imgaug.BoundingBoxesOnImage
    Shallow copy.


def project(self, from_shape, to_shape):

coords_proj = project_coords([(self.x1, self.y1), (self.x2, self.y2)],<EOL>from_shape, to_shape)<EOL>return self.copy(<EOL>x1=coords_proj[<NUM_LIT:0>][<NUM_LIT:0>],<EOL>y1=coords_proj[<NUM_LIT:0>][<NUM_LIT:1>],<EOL>x2=coords_proj[<NUM_LIT:1>][<NUM_LIT:0>],<EOL>y2=coords_proj[<NUM_LIT:1>][<NUM_LIT:1>],<EOL>label=self.label)<EOL>

Project the bounding box onto a differently shaped image.

E.g. if the bounding box is on its original image at
x1=(10 of 100 pixels) and y1=(20 of 100 pixels) and is projected onto
a new image with size (width=200, height=200), its new position will
be (x1=20, y1=40). (Analogous for x2/y2.)

This is intended for cases where the original image is resized.
It cannot be used for more complex changes (e.g. padding, cropping).

Parameters
----------
from_shape : tuple of int or ndarray
    Shape of the original image. (Before resize.)

to_shape : tuple of int or ndarray
    Shape of the new image. (After resize.)

Returns
-------
out : imgaug.BoundingBox
    BoundingBox object with new coordinates.


shape = normalize_shape(image)<EOL>if shape[<NUM_LIT:0>:<NUM_LIT:2>] == self.shape[<NUM_LIT:0>:<NUM_LIT:2>]:<EOL><INDENT>return self.deepcopy()<EOL><DEDENT>bounding_boxes = [bb.project(self.shape, shape)<EOL>for bb in self.bounding_boxes]<EOL>return BoundingBoxesOnImage(bounding_boxes, shape)<EOL>

Project bounding boxes from one image to a new one.

Parameters
----------
image : ndarray or tuple of int
    New image onto which the bounding boxes are to be projected.
    May also simply be that new image's shape tuple.

Returns
-------
bounding_boxes : imgaug.BoundingBoxesOnImage
    Object containing all projected bounding boxes.


assert all([<EOL>attr is None for attr_name, attr in self.__dict__.items()<EOL>if attr_name.endswith("<STR_LIT>")]),"<STR_LIT>""<STR_LIT>""<STR_LIT>"<EOL>images_unaug = nlib.normalize_images(self.images_unaug)<EOL>shapes = None<EOL>if images_unaug is not None:<EOL><INDENT>shapes = [image.shape for image in images_unaug]<EOL><DEDENT>return Batch(<EOL>images=images_unaug,<EOL>heatmaps=nlib.normalize_heatmaps(<EOL>self.heatmaps_unaug, shapes),<EOL>segmentation_maps=nlib.normalize_segmentation_maps(<EOL>self.segmentation_maps_unaug, shapes),<EOL>keypoints=nlib.normalize_keypoints(<EOL>self.keypoints_unaug, shapes),<EOL>bounding_boxes=nlib.normalize_bounding_boxes(<EOL>self.bounding_boxes_unaug, shapes),<EOL>polygons=nlib.normalize_polygons(<EOL>self.polygons_unaug, shapes),<EOL>line_strings=nlib.normalize_line_strings(<EOL>self.line_strings_unaug, shapes),<EOL>data=self.data<EOL>)<EOL>

Convert this unnormalized batch to an instance of Batch.

        As this method is intended to be called before augmentation, it
        assumes that none of the ``*_aug`` attributes is yet set.
        It will produce an AssertionError otherwise.

        The newly created Batch's ``*_unaug`` attributes will match the ones
        in this batch, just in normalized form.

        Returns
        -------
        imgaug.augmentables.batches.Batch
            The batch, with ``*_unaug`` attributes being normalized.


<EOL>batch = UnnormalizedBatch(<EOL>images=self.images_unaug,<EOL>heatmaps=self.heatmaps_unaug,<EOL>segmentation_maps=self.segmentation_maps_unaug,<EOL>keypoints=self.keypoints_unaug,<EOL>bounding_boxes=self.bounding_boxes_unaug,<EOL>polygons=self.polygons_unaug,<EOL>line_strings=self.line_strings_unaug,<EOL>data=batch_aug_norm.data<EOL>)<EOL>batch.images_aug = nlib.invert_normalize_images(<EOL>batch_aug_norm.images_aug, self.images_unaug)<EOL>batch.heatmaps_aug = nlib.invert_normalize_heatmaps(<EOL>batch_aug_norm.heatmaps_aug, self.heatmaps_unaug)<EOL>batch.segmentation_maps_aug = nlib.invert_normalize_segmentation_maps(<EOL>batch_aug_norm.segmentation_maps_aug, self.segmentation_maps_unaug)<EOL>batch.keypoints_aug = nlib.invert_normalize_keypoints(<EOL>batch_aug_norm.keypoints_aug, self.keypoints_unaug)<EOL>batch.bounding_boxes_aug = nlib.invert_normalize_bounding_boxes(<EOL>batch_aug_norm.bounding_boxes_aug, self.bounding_boxes_unaug)<EOL>batch.polygons_aug = nlib.invert_normalize_polygons(<EOL>batch_aug_norm.polygons_aug, self.polygons_unaug)<EOL>batch.line_strings_aug = nlib.invert_normalize_line_strings(<EOL>batch_aug_norm.line_strings_aug, self.line_strings_unaug)<EOL>return batch<EOL>

Fill this batch with (normalized) augmentation results.

This method receives a (normalized) Batch instance, takes all
``*_aug`` attributes out if it and assigns them to this
batch *in unnormalized form*. Hence, the datatypes of all ``*_aug``
attributes will match the datatypes of the ``*_unaug`` attributes.

Parameters
----------
batch_aug_norm: imgaug.augmentables.batches.Batch
    Batch after normalization and augmentation.

Returns
-------
imgaug.augmentables.batches.UnnormalizedBatch
    New UnnormalizedBatch instance. All ``*_unaug`` attributes are
    taken from the old UnnormalizedBatch (without deepcopying them)
    and all ``*_aug`` attributes are taken from `batch_normalized`
    converted to unnormalized form.


return HeatmapsOnImage(self.get_arr(), shape=self.shape, min_value=self.min_value, max_value=self.max_value)<EOL>

Create a deep copy of the Heatmaps object.

Returns
-------
imgaug.HeatmapsOnImage
    Deep copy.


@classmethod<EOL><INDENT>def change_normalization(cls, arr, source, target):<DEDENT>

ia.do_assert(ia.is_np_array(arr))<EOL>if isinstance(source, HeatmapsOnImage):<EOL><INDENT>source = (source.min_value, source.max_value)<EOL><DEDENT>else:<EOL><INDENT>ia.do_assert(isinstance(source, tuple))<EOL>ia.do_assert(len(source) == <NUM_LIT:2>)<EOL>ia.do_assert(source[<NUM_LIT:0>] < source[<NUM_LIT:1>])<EOL><DEDENT>if isinstance(target, HeatmapsOnImage):<EOL><INDENT>target = (target.min_value, target.max_value)<EOL><DEDENT>else:<EOL><INDENT>ia.do_assert(isinstance(target, tuple))<EOL>ia.do_assert(len(target) == <NUM_LIT:2>)<EOL>ia.do_assert(target[<NUM_LIT:0>] < target[<NUM_LIT:1>])<EOL><DEDENT>eps = np.finfo(arr.dtype).eps<EOL>mins_same = source[<NUM_LIT:0>] - <NUM_LIT:10>*eps < target[<NUM_LIT:0>] < source[<NUM_LIT:0>] + <NUM_LIT:10>*eps<EOL>maxs_same = source[<NUM_LIT:1>] - <NUM_LIT:10>*eps < target[<NUM_LIT:1>] < source[<NUM_LIT:1>] + <NUM_LIT:10>*eps<EOL>if mins_same and maxs_same:<EOL><INDENT>return np.copy(arr)<EOL><DEDENT>min_source, max_source = source<EOL>min_target, max_target = target<EOL>diff_source = max_source - min_source<EOL>diff_target = max_target - min_target<EOL>arr_0to1 = (arr - min_source) / diff_source<EOL>arr_target = min_target + arr_0to1 * diff_target<EOL>return arr_target<EOL>

Change the value range of a heatmap from one min-max to another min-max.

E.g. the value range may be changed from min=0.0, max=1.0 to min=-1.0, max=1.0.

Parameters
----------
arr : ndarray
    Heatmap array to modify.

source : tuple of float
    Current value range of the input array, given as (min, max), where both are float values.

target : tuple of float
    Desired output value range of the array, given as (min, max), where both are float values.

Returns
-------
arr_target : ndarray
    Input array, with value range projected to the desired target value range.


def resize(self, sizes, interpolation="<STR_LIT>"):

arr_0to1_resized = ia.imresize_single_image(self.arr_0to1, sizes, interpolation=interpolation)<EOL>arr_0to1_resized = np.clip(arr_0to1_resized, <NUM_LIT:0.0>, <NUM_LIT:1.0>)<EOL>return HeatmapsOnImage.from_0to1(arr_0to1_resized, shape=self.shape, min_value=self.min_value,<EOL>max_value=self.max_value)<EOL>

Resize the heatmap(s) array to the provided size given the provided interpolation.

Parameters
----------
sizes : float or iterable of int or iterable of float
    New size of the array in ``(height, width)``.
    See :func:`imgaug.imgaug.imresize_single_image` for details.

interpolation : None or str or int, optional
    The interpolation to use during resize.
    See :func:`imgaug.imgaug.imresize_single_image` for details.

Returns
-------
imgaug.HeatmapsOnImage
    Resized heatmaps object.


def pad_to_aspect_ratio(self, aspect_ratio, mode="<STR_LIT>", cval=<NUM_LIT:0.0>, return_pad_amounts=False):

arr_0to1_padded, pad_amounts = ia.pad_to_aspect_ratio(self.arr_0to1, aspect_ratio=aspect_ratio, mode=mode,<EOL>cval=cval, return_pad_amounts=True)<EOL>heatmaps = HeatmapsOnImage.from_0to1(arr_0to1_padded, shape=self.shape, min_value=self.min_value,<EOL>max_value=self.max_value)<EOL>if return_pad_amounts:<EOL><INDENT>return heatmaps, pad_amounts<EOL><DEDENT>else:<EOL><INDENT>return heatmaps<EOL><DEDENT>

Pad the heatmaps on their sides so that they match a target aspect ratio.

Depending on which dimension is smaller (height or width), only the corresponding
sides (left/right or top/bottom) will be padded. In each case, both of the sides will
be padded equally.

Parameters
----------
aspect_ratio : float
    Target aspect ratio, given as width/height. E.g. 2.0 denotes the image having twice
    as much width as height.

mode : str, optional
    Padding mode to use. See :func:`numpy.pad` for details.

cval : number, optional
    Value to use for padding if `mode` is ``constant``. See :func:`numpy.pad` for details.

return_pad_amounts : bool, optional
    If False, then only the padded image will be returned. If True, a tuple with two
    entries will be returned, where the first entry is the padded image and the second
    entry are the amounts by which each image side was padded. These amounts are again a
    tuple of the form (top, right, bottom, left), with each value being an integer.

Returns
-------
heatmaps : imgaug.HeatmapsOnImage
    Padded heatmaps as HeatmapsOnImage object.

pad_amounts : tuple of int
    Amounts by which the heatmaps were padded on each side, given as a tuple ``(top, right, bottom, left)``.
    This tuple is only returned if `return_pad_amounts` was set to True.


arr_0to1_reduced = ia.avg_pool(self.arr_0to1, block_size, cval=<NUM_LIT:0.0>)<EOL>return HeatmapsOnImage.from_0to1(arr_0to1_reduced, shape=self.shape, min_value=self.min_value,<EOL>max_value=self.max_value)<EOL>

Resize the heatmap(s) array using average pooling of a given block/kernel size.

Parameters
----------
block_size : int or tuple of int
    Size of each block of values to pool, aka kernel size. See :func:`imgaug.pool` for details.

Returns
-------
imgaug.HeatmapsOnImage
    Heatmaps after average pooling.


return not self.is_out_of_image(image, fully=True, partly=False)<EOL>

Estimate whether the polygon is at least partially inside the image area.

Parameters
----------
image : (H,W,...) ndarray or tuple of int
    Image dimensions to use.
    If an ndarray, its shape will be used.
    If a tuple, it is assumed to represent the image shape and must contain at least two integers.

Returns
-------
bool
    True if the polygon is at least partially inside the image area.
    False otherwise.


if len(self.exterior) < <NUM_LIT:3>:<EOL><INDENT>return False<EOL><DEDENT>return self.to_shapely_polygon().is_valid<EOL>

Estimate whether the polygon has a valid shape.

To to be considered valid, the polygons must be made up of at least 3 points and have concave shape.
Multiple consecutive points are allowed to have the same coordinates.

Returns
-------
bool
    True if polygon has at least 3 points and is concave, otherwise False.


if len(self.exterior) < <NUM_LIT:3>:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>poly = self.to_shapely_polygon()<EOL>return poly.area<EOL>

Estimate the area of the polygon.

Returns
-------
number
    Area of the polygon.


ia.do_assert(len(geoms) == <NUM_LIT:0> or all([isinstance(el, Polygon) for el in geoms]))<EOL>self.geoms = geoms<EOL>


<EOL>import shapely.geometry<EOL>return shapely.geometry.Polygon([(point[<NUM_LIT:0>], point[<NUM_LIT:1>]) for point in self.exterior])<EOL>

Convert this polygon to a Shapely polygon.

Returns
-------
shapely.geometry.Polygon
    The Shapely polygon matching this polygon's exterior.


xx = self.xx<EOL>return max(xx) - min(xx)<EOL>

Estimate the width of the polygon.

Returns
-------
number
    Width of the polygon.


shape = normalize_shape(image)<EOL>if shape[<NUM_LIT:0>:<NUM_LIT:2>] == self.shape[<NUM_LIT:0>:<NUM_LIT:2>]:<EOL><INDENT>return self.deepcopy()<EOL><DEDENT>polygons = [poly.project(self.shape, shape) for poly in self.polygons]<EOL>return PolygonsOnImage(polygons, shape)<EOL>

Project polygons from one image to a new one.

Parameters
----------
image : ndarray or tuple of int
    New image onto which the polygons are to be projected.
    May also simply be that new image's shape tuple.

Returns
-------
imgaug.PolygonsOnImage
    Object containing all projected polygons.


ia.do_assert(<NUM_LIT:0> <= point_idx < len(self.exterior))<EOL>if point_idx == <NUM_LIT:0>:<EOL><INDENT>return self.deepcopy()<EOL><DEDENT>exterior = np.concatenate(<EOL>(self.exterior[point_idx:, :], self.exterior[:point_idx, :]),<EOL>axis=<NUM_LIT:0><EOL>)<EOL>return self.deepcopy(exterior=exterior)<EOL>

Set the first point of the exterior to the given point based on its index.

Note: This method does *not* work in-place.

Parameters
----------
point_idx : int
    Index of the desired starting point.

Returns
-------
imgaug.Polygon
    Copy of this polygon with the new point order.


return self.exterior[:, <NUM_LIT:0>]<EOL>

Return the x-coordinates of all points in the exterior.

Returns
-------
(N,2) ndarray
    X-coordinates of all points in the exterior as a float32 ndarray.


def draw_on_image(self,<EOL>image,<EOL>color=(<NUM_LIT:0>, <NUM_LIT:255>, <NUM_LIT:0>), color_face=None,<EOL>color_lines=None, color_points=None,<EOL>alpha=<NUM_LIT:1.0>, alpha_face=None,<EOL>alpha_lines=None, alpha_points=None,<EOL>size=<NUM_LIT:1>, size_lines=None, size_points=None,<EOL>raise_if_out_of_image=False):

Draw all polygons onto a given image.

Parameters
----------
image : (H,W,C) ndarray
    The image onto which to draw the bounding boxes.
    This image should usually have the same shape as set in
    ``PolygonsOnImage.shape``.

color : iterable of int, optional
    The color to use for the whole polygons.
    Must correspond to the channel layout of the image. Usually RGB.
    The values for `color_face`, `color_lines` and `color_points`
    will be derived from this color if they are set to ``None``.
    This argument has no effect if `color_face`, `color_lines`
    and `color_points` are all set anything other than ``None``.

color_face : None or iterable of int, optional
    The color to use for the inner polygon areas (excluding perimeters).
    Must correspond to the channel layout of the image. Usually RGB.
    If this is ``None``, it will be derived from ``color * 1.0``.

color_lines : None or iterable of int, optional
    The color to use for the lines (aka perimeters/borders) of the
    polygons. Must correspond to the channel layout of the image.
    Usually RGB. If this is ``None``, it will be derived
    from ``color * 0.5``.

color_points : None or iterable of int, optional
    The color to use for the corner points of the polygons.
    Must correspond to the channel layout of the image. Usually RGB.
    If this is ``None``, it will be derived from ``color * 0.5``.

alpha : float, optional
    The opacity of the whole polygons, where ``1.0`` denotes
    completely visible polygons and ``0.0`` invisible ones.
    The values for `alpha_face`, `alpha_lines` and `alpha_points`
    will be derived from this alpha value if they are set to ``None``.
    This argument has no effect if `alpha_face`, `alpha_lines`
    and `alpha_points` are all set anything other than ``None``.

alpha_face : None or number, optional
    The opacity of the polygon's inner areas (excluding the perimeters),
    where ``1.0`` denotes completely visible inner areas and ``0.0``
    invisible ones.
    If this is ``None``, it will be derived from ``alpha * 0.5``.

alpha_lines : None or number, optional
    The opacity of the polygon's lines (aka perimeters/borders),
    where ``1.0`` denotes completely visible perimeters and ``0.0``
    invisible ones.
    If this is ``None``, it will be derived from ``alpha * 1.0``.

alpha_points : None or number, optional
    The opacity of the polygon's corner points, where ``1.0`` denotes
    completely visible corners and ``0.0`` invisible ones.
    Currently this is an on/off choice, i.e. only ``0.0`` or ``1.0``
    are allowed.
    If this is ``None``, it will be derived from ``alpha * 1.0``.

size : int, optional
    Size of the polygons.
    The sizes of the line and points are derived from this value,
    unless they are set.

size_lines : None or int, optional
    Thickness of the polygon lines (aka perimeter/border).
    If ``None``, this value is derived from `size`.

size_points : int, optional
    The size of all corner points. If set to ``C``, each corner point
    will be drawn as a square of size ``C x C``.

raise_if_out_of_image : bool, optional
    Whether to raise an error if any polygon is fully
    outside of the image. If set to False, no error will be raised and
    only the parts inside the image will be drawn.

Returns
-------
image : (H,W,C) ndarray
    Image with drawn polygons.


polys_clean = [<EOL>poly for poly in self.polygons<EOL>if not poly.is_out_of_image(self.shape, fully=fully, partly=partly)<EOL>]<EOL>return PolygonsOnImage(polys_clean, shape=self.shape)<EOL>

Remove all polygons that are fully or partially outside of the image.

Parameters
----------
fully : bool, optional
    Whether to remove polygons that are fully outside of the image.

partly : bool, optional
    Whether to remove polygons that are partially outside of the image.

Returns
-------
imgaug.PolygonsOnImage
    Reduced set of polygons, with those that were fully/partially
    outside of the image removed.


def copy(self, exterior=None, label=None):

return self.deepcopy(exterior=exterior, label=label)<EOL>

Create a shallow copy of the Polygon object.

Parameters
----------
exterior : list of imgaug.Keypoint or list of tuple or (N,2) ndarray, optional
    List of points defining the polygon. See :func:`imgaug.Polygon.__init__` for details.

label : None or str, optional
    If not None, then the label of the copied object will be set to this value.

Returns
-------
imgaug.Polygon
    Shallow copy.


def almost_equals(self, other, max_distance=<NUM_LIT>, points_per_edge=<NUM_LIT:8>):

if not isinstance(other, Polygon):<EOL><INDENT>return False<EOL><DEDENT>if self.label is not None or other.label is not None:<EOL><INDENT>if self.label is None:<EOL><INDENT>return False<EOL><DEDENT>if other.label is None:<EOL><INDENT>return False<EOL><DEDENT>if self.label != other.label:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return self.exterior_almost_equals(<EOL>other, max_distance=max_distance, points_per_edge=points_per_edge)<EOL>

Estimate if this polygon's and another's geometry/labels are similar.

This is the same as :func:`imgaug.Polygon.exterior_almost_equals` but
additionally compares the labels.

Parameters
----------
other
    The object to compare against. If not a Polygon, then False will
    be returned.

max_distance : float, optional
    See :func:`imgaug.augmentables.polys.Polygon.exterior_almost_equals`.

points_per_edge : int, optional
    See :func:`imgaug.augmentables.polys.Polygon.exterior_almost_equals`.

Returns
-------
bool
    Whether the two polygons can be viewed as equal. In the case of
    the exteriors this is an approximate test.


<EOL>import shapely.geometry<EOL>ia.do_assert(isinstance(polygon_shapely, shapely.geometry.Polygon))<EOL>if polygon_shapely.exterior is None or len(polygon_shapely.exterior.coords) == <NUM_LIT:0>:<EOL><INDENT>return Polygon([], label=label)<EOL><DEDENT>exterior = np.float32([[x, y] for (x, y) in polygon_shapely.exterior.coords])<EOL>return Polygon(exterior, label=label)<EOL>

Create a polygon from a Shapely polygon.

Note: This will remove any holes in the Shapely polygon.

Parameters
----------
polygon_shapely : shapely.geometry.Polygon
     The shapely polygon.

label : None or str, optional
    The label of the new polygon.

Returns
-------
imgaug.Polygon
    A polygon with the same exterior as the Shapely polygon.


from imgaug.augmentables.lines import LineString<EOL>if not closed or len(self.exterior) <= <NUM_LIT:1>:<EOL><INDENT>return LineString(self.exterior, label=self.label)<EOL><DEDENT>return LineString(<EOL>np.concatenate([self.exterior, self.exterior[<NUM_LIT:0>:<NUM_LIT:1>, :]], axis=<NUM_LIT:0>),<EOL>label=self.label)<EOL>

Convert this polygon's `exterior` to a ``LineString`` instance.

Parameters
----------
closed : bool, optional
    Whether to close the line string, i.e. to add the first point of
    the `exterior` also as the last point at the end of the line string.
    This has no effect if the polygon has a single point or zero
    points.

Returns
-------
imgaug.augmentables.lines.LineString
    Exterior of the polygon as a line string.


def deepcopy(self, exterior=None, label=None):

return Polygon(<EOL>exterior=np.copy(self.exterior) if exterior is None else exterior,<EOL>label=self.label if label is None else label<EOL>)<EOL>

Create a deep copy of the Polygon object.

Parameters
----------
exterior : list of Keypoint or list of tuple or (N,2) ndarray, optional
    List of points defining the polygon. See `imgaug.Polygon.__init__` for details.

label : None or str
    If not None, then the label of the copied object will be set to this value.

Returns
-------
imgaug.Polygon
    Deep copy.


return self.exterior[:, <NUM_LIT:1>]<EOL>

Return the y-coordinates of all points in the exterior.

Returns
-------
(N,2) ndarray
    Y-coordinates of all points in the exterior as a float32 ndarray.


<EOL>polys = [poly.deepcopy() for poly in self.polygons]<EOL>return PolygonsOnImage(polys, tuple(self.shape))<EOL>

Create a deep copy of the PolygonsOnImage object.

Returns
-------
imgaug.PolygonsOnImage
    Deep copy.


<EOL>import shapely.geometry<EOL>if self.is_out_of_image(image, fully=True, partly=False):<EOL><INDENT>return []<EOL><DEDENT>h, w = image.shape[<NUM_LIT:0>:<NUM_LIT:2>] if ia.is_np_array(image) else image[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>poly_shapely = self.to_shapely_polygon()<EOL>poly_image = shapely.geometry.Polygon([(<NUM_LIT:0>, <NUM_LIT:0>), (w, <NUM_LIT:0>), (w, h), (<NUM_LIT:0>, h)])<EOL>multipoly_inter_shapely = poly_shapely.intersection(poly_image)<EOL>if not isinstance(multipoly_inter_shapely, shapely.geometry.MultiPolygon):<EOL><INDENT>ia.do_assert(isinstance(multipoly_inter_shapely, shapely.geometry.Polygon))<EOL>multipoly_inter_shapely = shapely.geometry.MultiPolygon([multipoly_inter_shapely])<EOL><DEDENT>polygons = []<EOL>for poly_inter_shapely in multipoly_inter_shapely.geoms:<EOL><INDENT>polygons.append(Polygon.from_shapely(poly_inter_shapely, label=self.label))<EOL><DEDENT>polygons_reordered = []<EOL>for polygon in polygons:<EOL><INDENT>found = False<EOL>for x, y in self.exterior:<EOL><INDENT>closest_idx, dist = polygon.find_closest_point_index(x=x, y=y, return_distance=True)<EOL>if dist < <NUM_LIT>:<EOL><INDENT>polygon_reordered = polygon.change_first_point_by_index(closest_idx)<EOL>polygons_reordered.append(polygon_reordered)<EOL>found = True<EOL>break<EOL><DEDENT><DEDENT>ia.do_assert(found)  <EOL><DEDENT>return polygons_reordered<EOL>

Cut off all parts of the polygon that are outside of the image.

This operation may lead to new points being created.
As a single polygon may be split into multiple new polygons, the result
is always a list, which may contain more than one output polygon.

This operation will return an empty list if the polygon is completely
outside of the image plane.

Parameters
----------
image : (H,W,...) ndarray or tuple of int
    Image dimensions to use for the clipping of the polygon.
    If an ndarray, its shape will be used.
    If a tuple, it is assumed to represent the image shape and must
    contain at least two integers.

Returns
-------
list of imgaug.Polygon
    Polygon, clipped to fall within the image dimensions.
    Returned as a list, because the clipping can split the polygon into
    multiple parts. The list may also be empty, if the polygon was
    fully outside of the image plane.


return np.int32(np.round(self.yy))<EOL>

Return the y-coordinates of all points in the exterior, rounded to the closest integer value.

Returns
-------
(N,2) ndarray
    Y-coordinates of all points in the exterior, rounded to the closest integer value.
    Result dtype is int32.


<EOL>from imgaug.augmentables.kps import Keypoint<EOL>return [Keypoint(x=point[<NUM_LIT:0>], y=point[<NUM_LIT:1>]) for point in self.exterior]<EOL>

Convert this polygon's `exterior` to ``Keypoint`` instances.

Returns
-------
list of imgaug.Keypoint
    Exterior vertices as ``Keypoint`` instances.


return not self.is_out_of_image(image, fully=True, partly=True)<EOL>

Estimate whether the polygon is fully inside the image area.

Parameters
----------
image : (H,W,...) ndarray or tuple of int
    Image dimensions to use.
    If an ndarray, its shape will be used.
    If a tuple, it is assumed to represent the image shape and must contain at least two integers.

Returns
-------
bool
    True if the polygon is fully inside the image area.
    False otherwise.


def __init__(self, exterior, label=None):

<EOL>from imgaug.augmentables.kps import Keypoint<EOL>if isinstance(exterior, list):<EOL><INDENT>if not exterior:<EOL><INDENT>self.exterior = np.zeros((<NUM_LIT:0>, <NUM_LIT:2>), dtype=np.float32)<EOL><DEDENT>elif isinstance(exterior[<NUM_LIT:0>], Keypoint):<EOL><INDENT>self.exterior = np.float32([[point.x, point.y] for point in exterior])<EOL><DEDENT>else:<EOL><INDENT>self.exterior = np.float32([[point[<NUM_LIT:0>], point[<NUM_LIT:1>]] for point in exterior])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ia.do_assert(ia.is_np_array(exterior),<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>") % (exterior,))<EOL>ia.do_assert(exterior.ndim == <NUM_LIT:2> and exterior.shape[<NUM_LIT:1>] == <NUM_LIT:2>,<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>") % (<EOL>exterior.shape,))<EOL>self.exterior = np.float32(exterior)<EOL><DEDENT>if len(self.exterior) >= <NUM_LIT:2> and np.allclose(self.exterior[<NUM_LIT:0>, :], self.exterior[-<NUM_LIT:1>, :]):<EOL><INDENT>self.exterior = self.exterior[:-<NUM_LIT:1>]<EOL><DEDENT>self.label = label<EOL>


arr_resized = ia.imresize_single_image(self.arr, sizes, interpolation=interpolation)<EOL>arr_resized = np.clip(arr_resized, <NUM_LIT:0.0>, <NUM_LIT:1.0>)<EOL>segmap = SegmentationMapOnImage(arr_resized, shape=self.shape)<EOL>segmap.input_was = self.input_was<EOL>return segmap<EOL>

Resize the segmentation map array to the provided size given the provided interpolation.

Parameters
----------
sizes : float or iterable of int or iterable of float
    New size of the array in ``(height, width)``.
    See :func:`imgaug.imgaug.imresize_single_image` for details.

interpolation : None or str or int, optional
    The interpolation to use during resize.
    See :func:`imgaug.imgaug.imresize_single_image` for details.
    Note: The segmentation map is internally stored as multiple float-based heatmaps,
    making smooth interpolations potentially more reasonable than nearest neighbour
    interpolation.

Returns
-------
segmap : imgaug.SegmentationMapOnImage
    Resized segmentation map object.


def get_arr_int(self, background_threshold=<NUM_LIT>, background_class_id=None):

if self.input_was[<NUM_LIT:0>] in ["<STR_LIT:bool>", "<STR_LIT:float>"]:<EOL><INDENT>ia.do_assert(background_class_id is None,<EOL>"<STR_LIT>"<EOL>+ "<STR_LIT>")<EOL><DEDENT>if background_class_id is None:<EOL><INDENT>background_class_id = <NUM_LIT:0><EOL><DEDENT>channelwise_max_idx = np.argmax(self.arr, axis=<NUM_LIT:2>)<EOL>if self.input_was[<NUM_LIT:0>] in ["<STR_LIT:bool>", "<STR_LIT:float>"]:<EOL><INDENT>result = <NUM_LIT:1> + channelwise_max_idx<EOL><DEDENT>else:  <EOL><INDENT>result = channelwise_max_idx<EOL><DEDENT>if background_threshold is not None and background_threshold > <NUM_LIT:0>:<EOL><INDENT>probs = np.amax(self.arr, axis=<NUM_LIT:2>)<EOL>result[probs < background_threshold] = background_class_id<EOL><DEDENT>return result.astype(np.int32)<EOL>

Get the segmentation map array as an integer array of shape (H, W).

Each pixel in that array contains an integer value representing the pixel's class.
If multiple classes overlap, the one with the highest local float value is picked.
If that highest local value is below `background_threshold`, the method instead uses
the background class id as the pixel's class value.
By default, class id 0 is the background class. This may only be changed if the original
input to the segmentation map object was an integer map.

Parameters
----------
background_threshold : float, optional
    At each pixel, each class-heatmap has a value between 0.0 and 1.0. If none of the
    class-heatmaps has a value above this threshold, the method uses the background class
    id instead.

background_class_id : None or int, optional
    Class id to fall back to if no class-heatmap passes the threshold at a spatial
    location. May only be provided if the original input was an integer mask and in these
    cases defaults to 0. If the input were float or boolean masks, the background class id
    may not be set as it is assumed that the background is implicitly defined
    as 'any spatial location that has zero-like values in all masks'.

Returns
-------
result : (H,W) ndarray
    Segmentation map array (int32).
    If the original input consisted of boolean or float masks, then the highest possible
    class id is ``1+C``, where ``C`` is the number of provided float/boolean masks. The value
    ``0`` in the integer mask then denotes the background class.


def pad(self, top=<NUM_LIT:0>, right=<NUM_LIT:0>, bottom=<NUM_LIT:0>, left=<NUM_LIT:0>, mode="<STR_LIT>", cval=<NUM_LIT:0.0>):

arr_padded = ia.pad(self.arr, top=top, right=right, bottom=bottom, left=left, mode=mode, cval=cval)<EOL>segmap = SegmentationMapOnImage(arr_padded, shape=self.shape)<EOL>segmap.input_was = self.input_was<EOL>return segmap<EOL>

Pad the segmentation map on its top/right/bottom/left side.

Parameters
----------
top : int, optional
    Amount of pixels to add at the top side of the segmentation map. Must be 0 or greater.

right : int, optional
    Amount of pixels to add at the right side of the segmentation map. Must be 0 or greater.

bottom : int, optional
    Amount of pixels to add at the bottom side of the segmentation map. Must be 0 or greater.

left : int, optional
    Amount of pixels to add at the left side of the segmentation map. Must be 0 or greater.

mode : str, optional
    Padding mode to use. See :func:`numpy.pad` for details.

cval : number, optional
    Value to use for padding if `mode` is ``constant``. See :func:`numpy.pad` for details.

Returns
-------
segmap : imgaug.SegmentationMapOnImage
    Padded segmentation map of height ``H'=H+top+bottom`` and width ``W'=W+left+right``.


segmap = SegmentationMapOnImage(self.arr, shape=self.shape, nb_classes=self.nb_classes)<EOL>segmap.input_was = self.input_was<EOL>return segmap<EOL>

Create a deep copy of the segmentation map object.

Returns
-------
imgaug.SegmentationMapOnImage
    Deep copy.


def to_heatmaps(self, only_nonempty=False, not_none_if_no_nonempty=False):

<EOL>from imgaug.augmentables.heatmaps import HeatmapsOnImage<EOL>if not only_nonempty:<EOL><INDENT>return HeatmapsOnImage.from_0to1(self.arr, self.shape, min_value=<NUM_LIT:0.0>, max_value=<NUM_LIT:1.0>)<EOL><DEDENT>else:<EOL><INDENT>nonempty_mask = np.sum(self.arr, axis=(<NUM_LIT:0>, <NUM_LIT:1>)) > <NUM_LIT:0> + <NUM_LIT><EOL>if np.sum(nonempty_mask) == <NUM_LIT:0>:<EOL><INDENT>if not_none_if_no_nonempty:<EOL><INDENT>nonempty_mask[<NUM_LIT:0>] = True<EOL><DEDENT>else:<EOL><INDENT>return None, []<EOL><DEDENT><DEDENT>class_indices = np.arange(self.arr.shape[<NUM_LIT:2>])[nonempty_mask]<EOL>channels = self.arr[..., class_indices]<EOL>return HeatmapsOnImage(channels, self.shape, min_value=<NUM_LIT:0.0>, max_value=<NUM_LIT:1.0>), class_indices<EOL><DEDENT>

Convert segmentation map to heatmaps object.

Each segmentation map class will be represented as a single heatmap channel.

Parameters
----------
only_nonempty : bool, optional
    If True, then only heatmaps for classes that appear in the segmentation map will be
    generated. Additionally, a list of these class ids will be returned.

not_none_if_no_nonempty : bool, optional
    If `only_nonempty` is True and for a segmentation map no channel was non-empty,
    this function usually returns None as the heatmaps object. If however this parameter
    is set to True, a heatmaps object with one channel (representing class 0)
    will be returned as a fallback in these cases.

Returns
-------
imgaug.HeatmapsOnImage or None
    Segmentation map as a heatmaps object.
    If `only_nonempty` was set to True and no class appeared in the segmentation map,
    then this is None.

class_indices : list of int
    Class ids (0 to C-1) of the classes that were actually added to the heatmaps.
    Only returned if `only_nonempty` was set to True.


def Clouds(name=None, deterministic=False, random_state=None):

if name is None:<EOL><INDENT>name = "<STR_LIT>" % (ia.caller_name(),)<EOL><DEDENT>return meta.SomeOf((<NUM_LIT:1>, <NUM_LIT:2>), children=[<EOL>CloudLayer(<EOL>intensity_mean=(<NUM_LIT>, <NUM_LIT:255>), intensity_freq_exponent=(-<NUM_LIT>, -<NUM_LIT>), intensity_coarse_scale=<NUM_LIT:10>,<EOL>alpha_min=<NUM_LIT:0>, alpha_multiplier=(<NUM_LIT>, <NUM_LIT>), alpha_size_px_max=(<NUM_LIT:2>, <NUM_LIT:8>), alpha_freq_exponent=(-<NUM_LIT>, -<NUM_LIT>),<EOL>sparsity=(<NUM_LIT>, <NUM_LIT:1.0>), density_multiplier=(<NUM_LIT:0.5>, <NUM_LIT:1.0>)<EOL>),<EOL>CloudLayer(<EOL>intensity_mean=(<NUM_LIT>, <NUM_LIT:255>), intensity_freq_exponent=(-<NUM_LIT>, -<NUM_LIT:1.0>), intensity_coarse_scale=<NUM_LIT:10>,<EOL>alpha_min=<NUM_LIT:0>, alpha_multiplier=(<NUM_LIT:0.5>, <NUM_LIT:1.0>), alpha_size_px_max=(<NUM_LIT:64>, <NUM_LIT>), alpha_freq_exponent=(-<NUM_LIT>, -<NUM_LIT:1.0>),<EOL>sparsity=(<NUM_LIT:1.0>, <NUM_LIT>), density_multiplier=(<NUM_LIT>, <NUM_LIT>)<EOL>)<EOL>], random_order=False, name=name, deterministic=deterministic, random_state=random_state)<EOL>

Augmenter to draw clouds in images.

This is a wrapper around ``CloudLayer``. It executes 1 to 2 layers per image, leading to varying densities
and frequency patterns of clouds.

This augmenter seems to be fairly robust w.r.t. the image size. Tested with ``96x128``, ``192x256``
and ``960x1280``.

dtype support::

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

    - (1) Parameters of this augmenter are optimized for the value range of uint8.
          While other dtypes may be accepted, they will lead to images augmented in
          ways inappropriate for the respective dtype.

Parameters
----------
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.Clouds()

Creates an augmenter that adds clouds to images.


@classmethod<EOL><INDENT>def map_coordinates(cls, image, dx, dy, order=<NUM_LIT:1>, cval=<NUM_LIT:0>, mode="<STR_LIT>"):<DEDENT>

if order == <NUM_LIT:0> and image.dtype.name in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>raise Exception(("<STR_LIT>"<EOL>+ "<STR_LIT>") % (order, image.dtype.name))<EOL><DEDENT>input_dtype = image.dtype<EOL>if image.dtype.name == "<STR_LIT:bool>":<EOL><INDENT>image = image.astype(np.float32)<EOL><DEDENT>elif order == <NUM_LIT:1> and image.dtype.name in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>image = image.astype(np.float64)<EOL><DEDENT>elif order >= <NUM_LIT:2> and image.dtype.name == "<STR_LIT>":<EOL><INDENT>image = image.astype(np.int16)<EOL><DEDENT>elif order >= <NUM_LIT:2> and image.dtype.name == "<STR_LIT>":<EOL><INDENT>image = image.astype(np.float64)<EOL><DEDENT>shrt_max = <NUM_LIT><EOL>backend = "<STR_LIT>"<EOL>if order == <NUM_LIT:0>:<EOL><INDENT>bad_dtype_cv2 = (image.dtype.name in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:bool>"])<EOL><DEDENT>elif order == <NUM_LIT:1>:<EOL><INDENT>bad_dtype_cv2 = (image.dtype.name in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT:bool>"])<EOL><DEDENT>else:<EOL><INDENT>bad_dtype_cv2 = (image.dtype.name in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:bool>"])<EOL><DEDENT>bad_dx_shape_cv2 = (dx.shape[<NUM_LIT:0>] >= shrt_max or dx.shape[<NUM_LIT:1>] >= shrt_max)<EOL>bad_dy_shape_cv2 = (dy.shape[<NUM_LIT:0>] >= shrt_max or dy.shape[<NUM_LIT:1>] >= shrt_max)<EOL>if bad_dtype_cv2 or bad_dx_shape_cv2 or bad_dy_shape_cv2:<EOL><INDENT>backend = "<STR_LIT>"<EOL><DEDENT>ia.do_assert(image.ndim == <NUM_LIT:3>)<EOL>result = np.copy(image)<EOL>height, width = image.shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>if backend == "<STR_LIT>":<EOL><INDENT>h, w = image.shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>y, x = np.meshgrid(np.arange(h).astype(np.float32), np.arange(w).astype(np.float32), indexing='<STR_LIT>')<EOL>x_shifted = x + (-<NUM_LIT:1>) * dx<EOL>y_shifted = y + (-<NUM_LIT:1>) * dy<EOL>for c in sm.xrange(image.shape[<NUM_LIT:2>]):<EOL><INDENT>remapped_flat = ndimage.interpolation.map_coordinates(<EOL>image[..., c],<EOL>(y_shifted.flatten(), x_shifted.flatten()),<EOL>order=order,<EOL>cval=cval,<EOL>mode=mode<EOL>)<EOL>remapped = remapped_flat.reshape((height, width))<EOL>result[..., c] = remapped<EOL><DEDENT><DEDENT>else:<EOL><INDENT>h, w, nb_channels = image.shape<EOL>y, x = np.meshgrid(np.arange(h).astype(np.float32), np.arange(w).astype(np.float32), indexing='<STR_LIT>')<EOL>x_shifted = x + (-<NUM_LIT:1>) * dx<EOL>y_shifted = y + (-<NUM_LIT:1>) * dy<EOL>if image.dtype.kind == "<STR_LIT:f>":<EOL><INDENT>cval = float(cval)<EOL><DEDENT>else:<EOL><INDENT>cval = int(cval)<EOL><DEDENT>border_mode = cls._MAPPING_MODE_SCIPY_CV2[mode]<EOL>interpolation = cls._MAPPING_ORDER_SCIPY_CV2[order]<EOL>is_nearest_neighbour = (interpolation == cv2.INTER_NEAREST)<EOL>map1, map2 = cv2.convertMaps(x_shifted, y_shifted, cv2.CV_16SC2, nninterpolation=is_nearest_neighbour)<EOL>if nb_channels <= <NUM_LIT:4>:<EOL><INDENT>result = cv2.remap(image, map1, map2, interpolation=interpolation, borderMode=border_mode, borderValue=cval)<EOL>if image.ndim == <NUM_LIT:3> and result.ndim == <NUM_LIT:2>:<EOL><INDENT>result = result[..., np.newaxis]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>current_chan_idx = <NUM_LIT:0><EOL>result = []<EOL>while current_chan_idx < nb_channels:<EOL><INDENT>channels = image[..., current_chan_idx:current_chan_idx+<NUM_LIT:4>]<EOL>result_c =  cv2.remap(channels, map1, map2, interpolation=interpolation, borderMode=border_mode,<EOL>borderValue=cval)<EOL>if result_c.ndim == <NUM_LIT:2>:<EOL><INDENT>result_c = result_c[..., np.newaxis]<EOL><DEDENT>result.append(result_c)<EOL>current_chan_idx += <NUM_LIT:4><EOL><DEDENT>result = np.concatenate(result, axis=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>if result.dtype.name != input_dtype.name:<EOL><INDENT>result = iadt.restore_dtypes_(result, input_dtype)<EOL><DEDENT>return result<EOL>

backend="scipy"

    order=0
        * uint8: yes
        * uint16: yes
        * uint32: yes
        * uint64: no (produces array filled with only 0)
        * int8: yes
        * int16: yes
        * int32: yes
        * int64: no (produces array filled with <min_value> when testing with <max_value>)
        * float16: yes
        * float32: yes
        * float64: yes
        * float128: no (causes: 'data type no supported')
        * bool: yes

    order=1 to 5
        * uint*, int*: yes (rather loose test, to avoid having to re-compute the interpolation)
        * float16 - float64: yes (rather loose test, to avoid having to re-compute the interpolation)
        * float128: no (causes: 'data type no supported')
        * bool: yes

backend="cv2"

    order=0
        * uint8: yes
        * uint16: yes
        * uint32: no (causes: src data type = 6 is not supported)
        * uint64: no (silently converts to int32)
        * int8: yes
        * int16: yes
        * int32: yes
        * int64: no (silently converts to int32)
        * float16: yes
        * float32: yes
        * float64: yes
        * float128: no (causes: src data type = 13 is not supported)
        * bool: no (causes: src data type = 0 is not supported)

    order=1
        * uint8: yes
        * uint16: yes
        * uint32: no (causes: src data type = 6 is not supported)
        * uint64: no (causes: OpenCV(3.4.5) (...)/imgwarp.cpp:1805: error: (-215:Assertion failed) ifunc != 0
          in function 'remap')
        * int8: no (causes: OpenCV(3.4.5) (...)/imgwarp.cpp:1805: error: (-215:Assertion failed) ifunc != 0
          in function 'remap')
        * int16: no (causes: OpenCV(3.4.5) (...)/imgwarp.cpp:1805: error: (-215:Assertion failed) ifunc != 0
          in function 'remap')
        * int32: no (causes: OpenCV(3.4.5) (...)/imgwarp.cpp:1805: error: (-215:Assertion failed) ifunc != 0
          in function 'remap')
        * int64: no (causes: OpenCV(3.4.5) (...)/imgwarp.cpp:1805: error: (-215:Assertion failed) ifunc != 0
          in function 'remap')
        * float16: yes
        * float32: yes
        * float64: yes
        * float128: no (causes: src data type = 13 is not supported)
        * bool: no (causes: src data type = 0 is not supported)

    order=2 to 5:
        as order=1, but int16 supported


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 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.


def augment_batches(self, batches, hooks=None, background=False):

if isinstance(batches, (Batch, UnnormalizedBatch)):<EOL><INDENT>batches = [batches]<EOL><DEDENT>ia.do_assert(<EOL>(ia.is_iterable(batches)<EOL>and not ia.is_np_array(batches)<EOL>and not ia.is_string(batches))<EOL>or ia.is_generator(batches),<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>") % (type(batches),))<EOL>if background:<EOL><INDENT>ia.do_assert(<EOL>hooks is None,<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>def _normalize_batch(idx, batch):<EOL><INDENT>if isinstance(batch, Batch):<EOL><INDENT>batch_copy = batch.deepcopy()<EOL>batch_copy.data = (idx, batch_copy.data)<EOL>batch_normalized = batch_copy<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif isinstance(batch, UnnormalizedBatch):<EOL><INDENT>batch_copy = batch.to_normalized_batch()<EOL>batch_copy.data = (idx, batch_copy.data)<EOL>batch_normalized = batch_copy<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif ia.is_np_array(batch):<EOL><INDENT>ia.do_assert(<EOL>batch.ndim in (<NUM_LIT:3>, <NUM_LIT:4>),<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>") % (batch.shape,))<EOL>batch_normalized = Batch(images=batch, data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif isinstance(batch, list):<EOL><INDENT>if len(batch) == <NUM_LIT:0>:<EOL><INDENT>batch_normalized = Batch(data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif ia.is_np_array(batch[<NUM_LIT:0>]):<EOL><INDENT>batch_normalized = Batch(images=batch, data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif isinstance(batch[<NUM_LIT:0>], ia.HeatmapsOnImage):<EOL><INDENT>batch_normalized = Batch(heatmaps=batch, data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif isinstance(batch[<NUM_LIT:0>], ia.SegmentationMapOnImage):<EOL><INDENT>batch_normalized = Batch(segmentation_maps=batch,<EOL>data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif isinstance(batch[<NUM_LIT:0>], ia.KeypointsOnImage):<EOL><INDENT>batch_normalized = Batch(keypoints=batch, data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif isinstance(batch[<NUM_LIT:0>], ia.BoundingBoxesOnImage):<EOL><INDENT>batch_normalized = Batch(bounding_boxes=batch, data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>elif isinstance(batch[<NUM_LIT:0>], ia.PolygonsOnImage):<EOL><INDENT>batch_normalized = Batch(polygons=batch, data=(idx,))<EOL>batch_orig_dt = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>raise Exception(<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>") % (type(batch[<NUM_LIT:0>]),))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception(<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>") % (type(batch),))<EOL><DEDENT>if batch_orig_dt not in ["<STR_LIT>",<EOL>"<STR_LIT>"]:<EOL><INDENT>ia.warn_deprecated(<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>") % (<EOL>batch_orig_dt,))<EOL><DEDENT>return batch_normalized, batch_orig_dt<EOL><DEDENT>def _unnormalize_batch(batch_aug, batch_orig, batch_orig_dt):<EOL><INDENT>if batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = batch_aug<EOL>batch_unnormalized.data = batch_unnormalized.data[<NUM_LIT:1>]<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_aug.data = batch_aug.data[<NUM_LIT:1>]<EOL>batch_unnormalized =batch_orig.fill_from_augmented_normalized_batch(batch_aug)<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = batch_aug.images_aug<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = []<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = batch_aug.images_aug<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = batch_aug.heatmaps_aug<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = batch_aug.segmentation_maps_aug<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = batch_aug.keypoints_aug<EOL><DEDENT>elif batch_orig_dt == "<STR_LIT>":<EOL><INDENT>batch_unnormalized = batch_aug.bounding_boxes_aug<EOL><DEDENT>else:  <EOL><INDENT>ia.do_assert(batch_orig_dt == "<STR_LIT>")<EOL>batch_unnormalized = batch_aug.polygons_aug<EOL><DEDENT>return batch_unnormalized<EOL><DEDENT>if not background:<EOL><INDENT>for idx, batch in enumerate(batches):<EOL><INDENT>batch_normalized, batch_orig_dt = _normalize_batch(idx, batch)<EOL>batch_normalized = self.augment_batch(<EOL>batch_normalized, hooks=hooks)<EOL>batch_unnormalized = _unnormalize_batch(<EOL>batch_normalized, batch, batch_orig_dt)<EOL>yield batch_unnormalized<EOL><DEDENT><DEDENT>else:<EOL><INDENT>import imgaug.multicore as multicore<EOL>id_to_batch_orig = dict()<EOL>def load_batches():<EOL><INDENT>for idx, batch in enumerate(batches):<EOL><INDENT>batch_normalized, batch_orig_dt = _normalize_batch(<EOL>idx, batch)<EOL>id_to_batch_orig[idx] = (batch, batch_orig_dt)<EOL>yield batch_normalized<EOL><DEDENT><DEDENT>with multicore.Pool(self) as pool:<EOL><INDENT>for batch_aug in pool.imap_batches(load_batches()):<EOL><INDENT>idx = batch_aug.data[<NUM_LIT:0>]<EOL>assert idx in id_to_batch_orig<EOL>batch_orig, batch_orig_dt = id_to_batch_orig[idx]<EOL>batch_unnormalized = _unnormalize_batch(<EOL>batch_aug, batch_orig, batch_orig_dt)<EOL>del id_to_batch_orig[idx]<EOL>yield batch_unnormalized<EOL><DEDENT><DEDENT><DEDENT>

Augment multiple batches.

In contrast to other augment functions, this function _yields_ batches
instead of just returning a full list. This is more suited for most
training loops. It also supports augmentation on multiple cpu cores,
activated via the `background` flag.

Parameters
----------
batches : imgaug.augmentables.batches.Batch \
          or imgaug.augmentables.batches.UnnormalizedBatch \
          or iterable of imgaug.augmentables.batches.Batch \
          or iterable of imgaug.augmentables.batches.UnnormalizedBatch
    A single batch or a list of batches to augment.

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

background : bool, optional
    Whether to augment the batches in background processes.
    If true, hooks can currently not be used as that would require
    pickling functions.
    Note that multicore augmentation distributes the batches onto
    different CPU cores. It does not split the data within batches.
    It is therefore not sensible to use ``background=True`` for a
    single batch.
    Note also that multicore augmentation needs some time to start. It
    is therefore not recommended to use it for very few batches.

Yields
-------
imgaug.augmentables.batches.Batch \
          or imgaug.augmentables.batches.UnnormalizedBatch \
          or iterable of imgaug.augmentables.batches.Batch \
          or iterable of imgaug.augmentables.batches.UnnormalizedBatch
    Augmented batches.


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 augment_segmentation_maps(self, segmaps, parents=None, hooks=None):

input_was_single_instance = False<EOL>if isinstance(segmaps, ia.SegmentationMapOnImage):<EOL><INDENT>input_was_single_instance = True<EOL>segmaps = [segmaps]<EOL><DEDENT>heatmaps_with_nonempty = [segmap.to_heatmaps(only_nonempty=True, not_none_if_no_nonempty=True)<EOL>for segmap in segmaps]<EOL>heatmaps = [heatmaps_i for heatmaps_i, nonempty_class_indices_i in heatmaps_with_nonempty]<EOL>nonempty_class_indices = [nonempty_class_indices_i<EOL>for heatmaps_i, nonempty_class_indices_i in heatmaps_with_nonempty]<EOL>heatmaps_aug = self.augment_heatmaps(heatmaps, parents=parents, hooks=hooks)<EOL>segmaps_aug = []<EOL>for segmap, heatmaps_aug_i, nonempty_class_indices_i in zip(segmaps, heatmaps_aug, nonempty_class_indices):<EOL><INDENT>segmap_aug = ia.SegmentationMapOnImage.from_heatmaps(heatmaps_aug_i,<EOL>class_indices=nonempty_class_indices_i,<EOL>nb_classes=segmap.nb_classes)<EOL>segmap_aug.input_was = segmap.input_was<EOL>segmaps_aug.append(segmap_aug)<EOL><DEDENT>if input_was_single_instance:<EOL><INDENT>return segmaps_aug[<NUM_LIT:0>]<EOL><DEDENT>return segmaps_aug<EOL>

Augment segmentation maps.

Parameters
----------
segmaps : imgaug.SegmentationMapOnImage or \
          list of imgaug.SegmentationMapOnImage
    Segmentation map(s) to augment. Either a single heatmap or a list of
    segmentation maps.

parents : None or list of imgaug.augmenters.meta.Augmenter, optional
    Parent augmenters that have previously been called before the
    call to this function. Usually you can leave this parameter as None.
    It is set automatically for child augmenters.

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

Returns
-------
segmaps_aug : imgaug.SegmentationMapOnImage or \
              list of imgaug.SegmentationMapOnImage
    Corresponding augmented segmentation map(s).


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.


@abstractmethod<EOL><INDENT>def _augment_keypoints(self, keypoints_on_images, random_state, parents, hooks):<DEDENT>

raise NotImplementedError()<EOL>

Augment keypoints on multiple images.

This is the internal variation of ``augment_keypoints()``.
It is called from ``augment_keypoints()`` and should usually not be
called directly. It has to be implemented by every augmenter.
This method may transform the keypoints 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
----------
keypoints_on_images : list of imgaug.KeypointsOnImage
    Keypoints 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_keypoints`.

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

Returns
----------
list of imgaug.KeypointsOnImage
    The augmented keypoints.


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.