imgaug.augmentables.utils

imgaug.augmentables.utils.copy_augmentables(augmentables)[source]
imgaug.augmentables.utils.interpolate_point_pair(point_a, point_b, nb_steps)[source]

Interpolate N points on a line segment.

Parameters:
  • point_a (iterable of number) – Start point of the line segment, given as (x,y) coordinates.
  • point_b (iterable of number) – End point of the line segment, given as (x,y) coordinates.
  • nb_steps (int) – Number of points to interpolate between point_a and point_b.
Returns:

The interpolated points. Does not include point_a.

Return type:

list of tuple of number

imgaug.augmentables.utils.interpolate_points(points, nb_steps, closed=True)[source]

Interpolate N on each line segment in a line string.

Parameters:
  • points (iterable of iterable of number) – Points on the line segments, each one given as (x,y) coordinates. They are assumed to form one connected line string.
  • nb_steps (int) – Number of points to interpolate on each individual line string.
  • closed (bool, optional) – If True the output contains the last point in points. Otherwise it does not (but it will contain the interpolated points leading to the last point).
Returns:

Coordinates of points, with additional nb_steps new points interpolated between each point pair. If closed is False, the last point in points is not returned.

Return type:

list of tuple of number

imgaug.augmentables.utils.interpolate_points_by_max_distance(points, max_distance, closed=True)[source]

Interpolate points with distance d on a line string.

For a list of points A, B, C, if the distance between A and B is greater than max_distance, it will place at least one point between A and B at A + max_distance * (B - A). Multiple points can be placed between the two points if they are far enough away from each other. The process is repeated for B and C.

Parameters:
  • points (iterable of iterable of number) – Points on the line segments, each one given as (x,y) coordinates. They are assumed to form one connected line string.
  • max_distance (number) – Maximum distance between any two points in the result.
  • closed (bool, optional) – If True the output contains the last point in points. Otherwise it does not (but it will contain the interpolated points leading to the last point).
Returns:

Coordinates of points, with interpolated points added to the iterable. If closed is False, the last point in points is not returned.

Return type:

list of tuple of number

imgaug.augmentables.utils.normalize_shape(shape)[source]

Normalize a shape tuple or array to a shape tuple.

Parameters:shape (tuple of int or ndarray) – The input to normalize. May optionally be an array.
Returns:Shape tuple.
Return type:tuple of int
imgaug.augmentables.utils.project_coords(coords, from_shape, to_shape)[source]

Project coordinates from one image shape to another.

This performs a relative projection, e.g. a point at 60% of the old image width will be at 60% of the new image width after projection.

Parameters:
  • coords (ndarray or list of tuple of number) – Coordinates to project. Either an (N,2) numpy array or a list containing (x,y) coordinate tuple s.
  • from_shape (tuple of int or ndarray) – Old image shape.
  • to_shape (tuple of int or ndarray) – New image shape.
Returns:

Projected coordinates as (N,2) float32 numpy array.

Return type:

ndarray