imgaug.augmenters.blur

Augmenters that blur images.

List of augmenters:

class imgaug.augmenters.blur.AverageBlur(k=(1, 7), seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]

Bases: imgaug.augmenters.meta.Augmenter

Blur an image by computing simple means over neighbourhoods.

The padding behaviour around the image borders is cv2’s BORDER_REFLECT_101.

Supported dtypes:

  • uint8: yes; fully tested
  • uint16: yes; tested
  • uint32: no (1)
  • uint64: no (2)
  • int8: yes; tested (3)
  • int16: yes; tested
  • int32: no (4)
  • int64: no (5)
  • float16: yes; tested (6)
  • float32: yes; tested
  • float64: yes; tested
  • float128: no
  • bool: yes; tested (7)
    1. rejected by cv2.blur()
    1. loss of resolution in cv2.blur() (result is int32)
    1. int8 is mapped internally to int16, int8 itself leads to cv2 error “Unsupported combination of source format (=1), and buffer format (=4) in function ‘getRowSumFilter’” in cv2
    1. results too inaccurate
    1. loss of resolution in cv2.blur() (result is int32)
    1. float16 is mapped internally to float32
    1. bool is mapped internally to float32
Parameters:
  • k (int or tuple of int or tuple of tuple of int or imgaug.parameters.StochasticParameter or tuple of StochasticParameter, optional) –

    Kernel size to use.

    • If a single int, then that value will be used for the height and width of the kernel.
    • If a tuple of two int s (a, b), then the kernel size will be sampled from the interval [a..b].
    • If a tuple of two tuples of int s ((a, b), (c, d)), then per image a random kernel height will be sampled from the interval [a..b] and a random kernel width will be sampled from the interval [c..d].
    • If a StochasticParameter, then N samples will be drawn from that parameter per N input images, each representing the kernel size for the n-th image.
    • If a tuple (a, b), where either a or b is a tuple, then a and b will be treated according to the rules above. This leads to different values for height and width of the kernel.
  • seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See __init__().

  • name (None or str, optional) – See __init__().

  • random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.

  • deterministic (bool, optional) – Deprecated since 0.4.0. See method to_deterministic() for an alternative and for details about what the “deterministic mode” actually does.

Examples

>>> import imgaug.augmenters as iaa
>>> aug = iaa.AverageBlur(k=5)

Blur all images using a kernel size of 5x5.

>>> aug = iaa.AverageBlur(k=(2, 5))

Blur images using a varying kernel size, which is sampled (per image) uniformly from the interval [2..5].

>>> aug = iaa.AverageBlur(k=((5, 7), (1, 3)))

Blur images using a varying kernel size, which’s height is sampled (per image) uniformly from the interval [5..7] and which’s width is sampled (per image) uniformly from [1..3].

Methods

__call__(self, \*args, \*\*kwargs) Alias for augment().
augment(self[, return_batch, hooks]) Augment a batch.
augment_batch(self, batch[, hooks]) Deprecated.
augment_batch_(self, batch[, parents, hooks]) Augment a single batch in-place.
augment_batches(self, batches[, hooks, …]) Augment multiple batches.
augment_bounding_boxes(self, …[, parents, …]) Augment a batch of bounding boxes.
augment_heatmaps(self, heatmaps[, parents, …]) Augment a batch of heatmaps.
augment_image(self, image[, hooks]) Augment a single image.
augment_images(self, images[, parents, hooks]) Augment a batch of images.
augment_keypoints(self, keypoints_on_images) Augment a batch of keypoints/landmarks.
augment_line_strings(self, …[, parents, hooks]) Augment a batch of line strings.
augment_polygons(self, polygons_on_images[, …]) Augment a batch of polygons.
augment_segmentation_maps(self, segmaps[, …]) Augment a batch of segmentation maps.
copy(self) Create a shallow copy of this Augmenter instance.
copy_random_state(self, source[, recursive, …]) Copy the RNGs from a source augmenter sequence.
copy_random_state_(self, source[, …]) Copy the RNGs from a source augmenter sequence (in-place).
deepcopy(self) Create a deep copy of this Augmenter instance.
draw_grid(self, images, rows, cols) Augment images and draw the results as a single grid-like image.
find_augmenters(self, func[, parents, flat]) Find augmenters that match a condition.
find_augmenters_by_name(self, name[, regex, …]) Find augmenter(s) by name.
find_augmenters_by_names(self, names[, …]) Find augmenter(s) by names.
get_all_children(self[, flat]) Get all children of this augmenter as a list.
get_children_lists(self) Get a list of lists of children of this augmenter.
get_parameters(self) See get_parameters().
localize_random_state(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
localize_random_state_(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
pool(self[, processes, maxtasksperchild, seed]) Create a pool used for multicore augmentation.
remove_augmenters(self, func[, copy, …]) Remove this augmenter or children that match a condition.
remove_augmenters_(self, func[, parents]) Remove in-place children of this augmenter that match a condition.
remove_augmenters_inplace(self, func[, parents]) Deprecated.
reseed(self[, random_state, deterministic_too]) Deprecated.
seed_(self[, entropy, deterministic_too]) Seed this augmenter and all of its children.
show_grid(self, images, rows, cols) Augment images and plot the results as a single grid-like image.
to_deterministic(self[, n]) Convert this augmenter from a stochastic to a deterministic one.
get_parameters(self)[source]

See get_parameters().

class imgaug.augmenters.blur.BilateralBlur(d=(1, 9), sigma_color=(10, 250), sigma_space=(10, 250), seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]

Bases: imgaug.augmenters.meta.Augmenter

Blur/Denoise an image using a bilateral filter.

Bilateral filters blur homogenous and textured areas, while trying to preserve edges.

See http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#bilateralfilter for more information regarding the parameters.

Supported dtypes:

  • uint8: yes; not tested
  • uint16: ?
  • uint32: ?
  • uint64: ?
  • int8: ?
  • int16: ?
  • int32: ?
  • int64: ?
  • float16: ?
  • float32: ?
  • float64: ?
  • float128: ?
  • bool: ?
Parameters:
  • d (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) – Diameter of each pixel neighborhood with value range [1 .. inf). High values for d lead to significantly worse performance. Values equal or less than 10 seem to be good. Use <5 for real-time applications.

    • If a single int, then that value will be used for the diameter.
    • If a tuple of two int s (a, b), then the diameter will be a value sampled from the interval [a..b].
    • If a list, then a random value will be sampled from that list per image.
    • If a StochasticParameter, then N samples will be drawn from that parameter per N input images, each representing the diameter for the n-th image. Expected to be discrete.
  • sigma_color (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Filter sigma in the color space with value range [1, inf). A large value of the parameter means that farther colors within the pixel neighborhood (see sigma_space) will be mixed together, resulting in larger areas of semi-equal color.

    • If a single int, then that value will be used for the diameter.
    • If a tuple of two int s (a, b), then the diameter will be a value sampled from the interval [a, b].
    • If a list, then a random value will be sampled from that list per image.
    • If a StochasticParameter, then N samples will be drawn from that parameter per N input images, each representing the diameter for the n-th image. Expected to be discrete.
  • sigma_space (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Filter sigma in the coordinate space with value range [1, inf). A large value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigma_color).

    • If a single int, then that value will be used for the diameter.
    • If a tuple of two int s (a, b), then the diameter will be a value sampled from the interval [a, b].
    • If a list, then a random value will be sampled from that list per image.
    • If a StochasticParameter, then N samples will be drawn from that parameter per N input images, each representing the diameter for the n-th image. Expected to be discrete.
  • seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See __init__().

  • name (None or str, optional) – See __init__().

  • random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.

  • deterministic (bool, optional) – Deprecated since 0.4.0. See method to_deterministic() for an alternative and for details about what the “deterministic mode” actually does.

Examples

>>> import imgaug.augmenters as iaa
>>> aug = iaa.BilateralBlur(
>>>     d=(3, 10), sigma_color=(10, 250), sigma_space=(10, 250))

Blur all images using a bilateral filter with a max distance sampled uniformly from the interval [3, 10] and wide ranges for sigma_color and sigma_space.

Methods

__call__(self, \*args, \*\*kwargs) Alias for augment().
augment(self[, return_batch, hooks]) Augment a batch.
augment_batch(self, batch[, hooks]) Deprecated.
augment_batch_(self, batch[, parents, hooks]) Augment a single batch in-place.
augment_batches(self, batches[, hooks, …]) Augment multiple batches.
augment_bounding_boxes(self, …[, parents, …]) Augment a batch of bounding boxes.
augment_heatmaps(self, heatmaps[, parents, …]) Augment a batch of heatmaps.
augment_image(self, image[, hooks]) Augment a single image.
augment_images(self, images[, parents, hooks]) Augment a batch of images.
augment_keypoints(self, keypoints_on_images) Augment a batch of keypoints/landmarks.
augment_line_strings(self, …[, parents, hooks]) Augment a batch of line strings.
augment_polygons(self, polygons_on_images[, …]) Augment a batch of polygons.
augment_segmentation_maps(self, segmaps[, …]) Augment a batch of segmentation maps.
copy(self) Create a shallow copy of this Augmenter instance.
copy_random_state(self, source[, recursive, …]) Copy the RNGs from a source augmenter sequence.
copy_random_state_(self, source[, …]) Copy the RNGs from a source augmenter sequence (in-place).
deepcopy(self) Create a deep copy of this Augmenter instance.
draw_grid(self, images, rows, cols) Augment images and draw the results as a single grid-like image.
find_augmenters(self, func[, parents, flat]) Find augmenters that match a condition.
find_augmenters_by_name(self, name[, regex, …]) Find augmenter(s) by name.
find_augmenters_by_names(self, names[, …]) Find augmenter(s) by names.
get_all_children(self[, flat]) Get all children of this augmenter as a list.
get_children_lists(self) Get a list of lists of children of this augmenter.
get_parameters(self) See get_parameters().
localize_random_state(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
localize_random_state_(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
pool(self[, processes, maxtasksperchild, seed]) Create a pool used for multicore augmentation.
remove_augmenters(self, func[, copy, …]) Remove this augmenter or children that match a condition.
remove_augmenters_(self, func[, parents]) Remove in-place children of this augmenter that match a condition.
remove_augmenters_inplace(self, func[, parents]) Deprecated.
reseed(self[, random_state, deterministic_too]) Deprecated.
seed_(self[, entropy, deterministic_too]) Seed this augmenter and all of its children.
show_grid(self, images, rows, cols) Augment images and plot the results as a single grid-like image.
to_deterministic(self[, n]) Convert this augmenter from a stochastic to a deterministic one.
get_parameters(self)[source]

See get_parameters().

class imgaug.augmenters.blur.GaussianBlur(sigma=(0.0, 3.0), seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]

Bases: imgaug.augmenters.meta.Augmenter

Augmenter to blur images using gaussian kernels.

Supported dtypes:

See ~imgaug.augmenters.blur.blur_gaussian_(backend="auto").

Parameters:
  • sigma (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Standard deviation of the gaussian kernel. Values in the range 0.0 (no blur) to 3.0 (strong blur) are common.

    • If a single float, that value will always be used as the standard deviation.
    • If a tuple (a, b), then a random value from the interval [a, b] will be picked per image.
    • If a list, then a random value will be sampled per image from that list.
    • If a StochasticParameter, then N samples will be drawn from that parameter per N input images.
  • seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See __init__().

  • name (None or str, optional) – See __init__().

  • random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.

  • deterministic (bool, optional) – Deprecated since 0.4.0. See method to_deterministic() for an alternative and for details about what the “deterministic mode” actually does.

Examples

>>> import imgaug.augmenters as iaa
>>> aug = iaa.GaussianBlur(sigma=1.5)

Blur all images using a gaussian kernel with a standard deviation of 1.5.

>>> aug = iaa.GaussianBlur(sigma=(0.0, 3.0))

Blur images using a gaussian kernel with a random standard deviation sampled uniformly (per image) from the interval [0.0, 3.0].

Methods

__call__(self, \*args, \*\*kwargs) Alias for augment().
augment(self[, return_batch, hooks]) Augment a batch.
augment_batch(self, batch[, hooks]) Deprecated.
augment_batch_(self, batch[, parents, hooks]) Augment a single batch in-place.
augment_batches(self, batches[, hooks, …]) Augment multiple batches.
augment_bounding_boxes(self, …[, parents, …]) Augment a batch of bounding boxes.
augment_heatmaps(self, heatmaps[, parents, …]) Augment a batch of heatmaps.
augment_image(self, image[, hooks]) Augment a single image.
augment_images(self, images[, parents, hooks]) Augment a batch of images.
augment_keypoints(self, keypoints_on_images) Augment a batch of keypoints/landmarks.
augment_line_strings(self, …[, parents, hooks]) Augment a batch of line strings.
augment_polygons(self, polygons_on_images[, …]) Augment a batch of polygons.
augment_segmentation_maps(self, segmaps[, …]) Augment a batch of segmentation maps.
copy(self) Create a shallow copy of this Augmenter instance.
copy_random_state(self, source[, recursive, …]) Copy the RNGs from a source augmenter sequence.
copy_random_state_(self, source[, …]) Copy the RNGs from a source augmenter sequence (in-place).
deepcopy(self) Create a deep copy of this Augmenter instance.
draw_grid(self, images, rows, cols) Augment images and draw the results as a single grid-like image.
find_augmenters(self, func[, parents, flat]) Find augmenters that match a condition.
find_augmenters_by_name(self, name[, regex, …]) Find augmenter(s) by name.
find_augmenters_by_names(self, names[, …]) Find augmenter(s) by names.
get_all_children(self[, flat]) Get all children of this augmenter as a list.
get_children_lists(self) Get a list of lists of children of this augmenter.
get_parameters(self) See get_parameters().
localize_random_state(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
localize_random_state_(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
pool(self[, processes, maxtasksperchild, seed]) Create a pool used for multicore augmentation.
remove_augmenters(self, func[, copy, …]) Remove this augmenter or children that match a condition.
remove_augmenters_(self, func[, parents]) Remove in-place children of this augmenter that match a condition.
remove_augmenters_inplace(self, func[, parents]) Deprecated.
reseed(self[, random_state, deterministic_too]) Deprecated.
seed_(self[, entropy, deterministic_too]) Seed this augmenter and all of its children.
show_grid(self, images, rows, cols) Augment images and plot the results as a single grid-like image.
to_deterministic(self[, n]) Convert this augmenter from a stochastic to a deterministic one.
get_parameters(self)[source]

See get_parameters().

class imgaug.augmenters.blur.MeanShiftBlur(spatial_radius=(5.0, 40.0), color_radius=(5.0, 40.0), seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]

Bases: imgaug.augmenters.meta.Augmenter

Apply a pyramidic mean shift filter to each image.

See also blur_mean_shift_() for details.

This augmenter expects input images of shape (H,W) or (H,W,1) or (H,W,3).

Note

This augmenter is quite slow.

Added in 0.4.0.

Supported dtypes:

See blur_mean_shift_().

Parameters:
  • spatial_radius (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) –

    Spatial radius for pixels that are assumed to be similar.

    • If number: Exactly that value will be used for all images.
    • If tuple (a, b): A random value will be uniformly sampled per image from the interval [a, b).
    • If list: A random value will be sampled from that list per image.
    • If StochasticParameter: The parameter will be queried once per batch for (N,) values with N denoting the number of images.
  • color_radius (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) –

    Color radius for pixels that are assumed to be similar.

    • If number: Exactly that value will be used for all images.
    • If tuple (a, b): A random value will be uniformly sampled per image from the interval [a, b).
    • If list: A random value will be sampled from that list per image.
    • If StochasticParameter: The parameter will be queried once per batch for (N,) values with N denoting the number of images.
  • seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See __init__().

  • name (None or str, optional) – See __init__().

  • random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.

  • deterministic (bool, optional) – Deprecated since 0.4.0. See method to_deterministic() for an alternative and for details about what the “deterministic mode” actually does.

Examples

>>> import imgaug.augmenters as iaa
>>> aug = iaa.MeanShiftBlur()

Create a mean shift blur augmenter.

Methods

__call__(self, \*args, \*\*kwargs) Alias for augment().
augment(self[, return_batch, hooks]) Augment a batch.
augment_batch(self, batch[, hooks]) Deprecated.
augment_batch_(self, batch[, parents, hooks]) Augment a single batch in-place.
augment_batches(self, batches[, hooks, …]) Augment multiple batches.
augment_bounding_boxes(self, …[, parents, …]) Augment a batch of bounding boxes.
augment_heatmaps(self, heatmaps[, parents, …]) Augment a batch of heatmaps.
augment_image(self, image[, hooks]) Augment a single image.
augment_images(self, images[, parents, hooks]) Augment a batch of images.
augment_keypoints(self, keypoints_on_images) Augment a batch of keypoints/landmarks.
augment_line_strings(self, …[, parents, hooks]) Augment a batch of line strings.
augment_polygons(self, polygons_on_images[, …]) Augment a batch of polygons.
augment_segmentation_maps(self, segmaps[, …]) Augment a batch of segmentation maps.
copy(self) Create a shallow copy of this Augmenter instance.
copy_random_state(self, source[, recursive, …]) Copy the RNGs from a source augmenter sequence.
copy_random_state_(self, source[, …]) Copy the RNGs from a source augmenter sequence (in-place).
deepcopy(self) Create a deep copy of this Augmenter instance.
draw_grid(self, images, rows, cols) Augment images and draw the results as a single grid-like image.
find_augmenters(self, func[, parents, flat]) Find augmenters that match a condition.
find_augmenters_by_name(self, name[, regex, …]) Find augmenter(s) by name.
find_augmenters_by_names(self, names[, …]) Find augmenter(s) by names.
get_all_children(self[, flat]) Get all children of this augmenter as a list.
get_children_lists(self) Get a list of lists of children of this augmenter.
get_parameters(self) See get_parameters().
localize_random_state(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
localize_random_state_(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
pool(self[, processes, maxtasksperchild, seed]) Create a pool used for multicore augmentation.
remove_augmenters(self, func[, copy, …]) Remove this augmenter or children that match a condition.
remove_augmenters_(self, func[, parents]) Remove in-place children of this augmenter that match a condition.
remove_augmenters_inplace(self, func[, parents]) Deprecated.
reseed(self[, random_state, deterministic_too]) Deprecated.
seed_(self[, entropy, deterministic_too]) Seed this augmenter and all of its children.
show_grid(self, images, rows, cols) Augment images and plot the results as a single grid-like image.
to_deterministic(self[, n]) Convert this augmenter from a stochastic to a deterministic one.
get_parameters(self)[source]

See get_parameters().

class imgaug.augmenters.blur.MedianBlur(k=(1, 7), seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]

Bases: imgaug.augmenters.meta.Augmenter

Blur an image by computing median values over neighbourhoods.

Median blurring can be used to remove small dirt from images. At larger kernel sizes, its effects have some similarity with Superpixels.

Supported dtypes:

  • uint8: yes; fully tested
  • uint16: ?
  • uint32: ?
  • uint64: ?
  • int8: ?
  • int16: ?
  • int32: ?
  • int64: ?
  • float16: ?
  • float32: ?
  • float64: ?
  • float128: ?
  • bool: ?
Parameters:
  • k (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) –

    Kernel size.

    • If a single int, then that value will be used for the height and width of the kernel. Must be an odd value.
    • If a tuple of two ints (a, b), then the kernel size will be an odd value sampled from the interval [a..b]. a and b must both be odd values.
    • If a list, then a random value will be sampled from that list per image.
    • If a StochasticParameter, then N samples will be drawn from that parameter per N input images, each representing the kernel size for the nth image. Expected to be discrete. If a sampled value is not odd, then that value will be increased by 1.
  • seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See __init__().

  • name (None or str, optional) – See __init__().

  • random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.

  • deterministic (bool, optional) – Deprecated since 0.4.0. See method to_deterministic() for an alternative and for details about what the “deterministic mode” actually does.

Examples

>>> import imgaug.augmenters as iaa
>>> aug = iaa.MedianBlur(k=5)

Blur all images using a kernel size of 5x5.

>>> aug = iaa.MedianBlur(k=(3, 7))

Blur images using varying kernel sizes, which are sampled uniformly from the interval [3..7]. Only odd values will be sampled, i.e. 3 or 5 or 7.

Methods

__call__(self, \*args, \*\*kwargs) Alias for augment().
augment(self[, return_batch, hooks]) Augment a batch.
augment_batch(self, batch[, hooks]) Deprecated.
augment_batch_(self, batch[, parents, hooks]) Augment a single batch in-place.
augment_batches(self, batches[, hooks, …]) Augment multiple batches.
augment_bounding_boxes(self, …[, parents, …]) Augment a batch of bounding boxes.
augment_heatmaps(self, heatmaps[, parents, …]) Augment a batch of heatmaps.
augment_image(self, image[, hooks]) Augment a single image.
augment_images(self, images[, parents, hooks]) Augment a batch of images.
augment_keypoints(self, keypoints_on_images) Augment a batch of keypoints/landmarks.
augment_line_strings(self, …[, parents, hooks]) Augment a batch of line strings.
augment_polygons(self, polygons_on_images[, …]) Augment a batch of polygons.
augment_segmentation_maps(self, segmaps[, …]) Augment a batch of segmentation maps.
copy(self) Create a shallow copy of this Augmenter instance.
copy_random_state(self, source[, recursive, …]) Copy the RNGs from a source augmenter sequence.
copy_random_state_(self, source[, …]) Copy the RNGs from a source augmenter sequence (in-place).
deepcopy(self) Create a deep copy of this Augmenter instance.
draw_grid(self, images, rows, cols) Augment images and draw the results as a single grid-like image.
find_augmenters(self, func[, parents, flat]) Find augmenters that match a condition.
find_augmenters_by_name(self, name[, regex, …]) Find augmenter(s) by name.
find_augmenters_by_names(self, names[, …]) Find augmenter(s) by names.
get_all_children(self[, flat]) Get all children of this augmenter as a list.
get_children_lists(self) Get a list of lists of children of this augmenter.
get_parameters(self) See get_parameters().
localize_random_state(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
localize_random_state_(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
pool(self[, processes, maxtasksperchild, seed]) Create a pool used for multicore augmentation.
remove_augmenters(self, func[, copy, …]) Remove this augmenter or children that match a condition.
remove_augmenters_(self, func[, parents]) Remove in-place children of this augmenter that match a condition.
remove_augmenters_inplace(self, func[, parents]) Deprecated.
reseed(self[, random_state, deterministic_too]) Deprecated.
seed_(self[, entropy, deterministic_too]) Seed this augmenter and all of its children.
show_grid(self, images, rows, cols) Augment images and plot the results as a single grid-like image.
to_deterministic(self[, n]) Convert this augmenter from a stochastic to a deterministic one.
get_parameters(self)[source]

See get_parameters().

class imgaug.augmenters.blur.MotionBlur(k=(3, 7), angle=(0, 360), direction=(-1.0, 1.0), order=1, seed=None, name=None, random_state='deprecated', deterministic='deprecated')[source]

Bases: imgaug.augmenters.convolutional.Convolve

Blur images in a way that fakes camera or object movements.

Supported dtypes:

See Convolve.

Parameters:
  • k (int or tuple of int or list of int or imgaug.parameters.StochasticParameter, optional) –

    Kernel size to use.

    • If a single int, then that value will be used for the height and width of the kernel.
    • If a tuple of two int s (a, b), then the kernel size will be sampled from the interval [a..b].
    • If a list, then a random value will be sampled from that list per image.
    • If a StochasticParameter, then N samples will be drawn from that parameter per N input images, each representing the kernel size for the n-th image.
  • angle (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Angle of the motion blur in degrees (clockwise, relative to top center direction).

    • If a number, exactly that value will be used.
    • If a tuple (a, b), a random value from the interval [a, b] will be uniformly sampled per image.
    • If a list, then a random value will be sampled from that list per image.
    • If a StochasticParameter, a value will be sampled from the parameter per image.
  • direction (number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional) – Forward/backward direction of the motion blur. Lower values towards -1.0 will point the motion blur towards the back (with angle provided via angle). Higher values towards 1.0 will point the motion blur forward. A value of 0.0 leads to a uniformly (but still angled) motion blur.

    • If a number, exactly that value will be used.
    • If a tuple (a, b), a random value from the interval [a, b] will be uniformly sampled per image.
    • If a list, then a random value will be sampled from that list per image.
    • If a StochasticParameter, a value will be sampled from the parameter per image.
  • order (int or iterable of int or imgaug.ALL or imgaug.parameters.StochasticParameter, optional) – Interpolation order to use when rotating the kernel according to angle. See __init__(). Recommended to be 0 or 1, with 0 being faster, but less continuous/smooth as angle is changed, particularly around multiple of 45 degrees.

  • seed (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – See __init__().

  • name (None or str, optional) – See __init__().

  • random_state (None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState, optional) – Old name for parameter seed. Its usage will not yet cause a deprecation warning, but it is still recommended to use seed now. Outdated since 0.4.0.

  • deterministic (bool, optional) – Deprecated since 0.4.0. See method to_deterministic() for an alternative and for details about what the “deterministic mode” actually does.

Examples

>>> import imgaug.augmenters as iaa
>>> aug = iaa.MotionBlur(k=15)

Apply motion blur with a kernel size of 15x15 pixels to images.

>>> aug = iaa.MotionBlur(k=15, angle=[-45, 45])

Apply motion blur with a kernel size of 15x15 pixels and a blur angle of either -45 or 45 degrees (randomly picked per image).

Methods

__call__(self, \*args, \*\*kwargs) Alias for augment().
augment(self[, return_batch, hooks]) Augment a batch.
augment_batch(self, batch[, hooks]) Deprecated.
augment_batch_(self, batch[, parents, hooks]) Augment a single batch in-place.
augment_batches(self, batches[, hooks, …]) Augment multiple batches.
augment_bounding_boxes(self, …[, parents, …]) Augment a batch of bounding boxes.
augment_heatmaps(self, heatmaps[, parents, …]) Augment a batch of heatmaps.
augment_image(self, image[, hooks]) Augment a single image.
augment_images(self, images[, parents, hooks]) Augment a batch of images.
augment_keypoints(self, keypoints_on_images) Augment a batch of keypoints/landmarks.
augment_line_strings(self, …[, parents, hooks]) Augment a batch of line strings.
augment_polygons(self, polygons_on_images[, …]) Augment a batch of polygons.
augment_segmentation_maps(self, segmaps[, …]) Augment a batch of segmentation maps.
copy(self) Create a shallow copy of this Augmenter instance.
copy_random_state(self, source[, recursive, …]) Copy the RNGs from a source augmenter sequence.
copy_random_state_(self, source[, …]) Copy the RNGs from a source augmenter sequence (in-place).
deepcopy(self) Create a deep copy of this Augmenter instance.
draw_grid(self, images, rows, cols) Augment images and draw the results as a single grid-like image.
find_augmenters(self, func[, parents, flat]) Find augmenters that match a condition.
find_augmenters_by_name(self, name[, regex, …]) Find augmenter(s) by name.
find_augmenters_by_names(self, names[, …]) Find augmenter(s) by names.
get_all_children(self[, flat]) Get all children of this augmenter as a list.
get_children_lists(self) Get a list of lists of children of this augmenter.
get_parameters(self) See get_parameters().
localize_random_state(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
localize_random_state_(self[, recursive]) Assign augmenter-specific RNGs to this augmenter and its children.
pool(self[, processes, maxtasksperchild, seed]) Create a pool used for multicore augmentation.
remove_augmenters(self, func[, copy, …]) Remove this augmenter or children that match a condition.
remove_augmenters_(self, func[, parents]) Remove in-place children of this augmenter that match a condition.
remove_augmenters_inplace(self, func[, parents]) Deprecated.
reseed(self[, random_state, deterministic_too]) Deprecated.
seed_(self[, entropy, deterministic_too]) Seed this augmenter and all of its children.
show_grid(self, images, rows, cols) Augment images and plot the results as a single grid-like image.
to_deterministic(self[, n]) Convert this augmenter from a stochastic to a deterministic one.
imgaug.augmenters.blur.blur_gaussian_(image, sigma, ksize=None, backend='auto', eps=0.001)[source]

Blur an image using gaussian blurring in-place.

This operation may change the input image in-place.

Supported dtypes:

if (backend=”auto”):

  • uint8: yes; fully tested (1)
  • uint16: yes; tested (1)
  • uint32: yes; tested (2)
  • uint64: yes; tested (2)
  • int8: yes; tested (1)
  • int16: yes; tested (1)
  • int32: yes; tested (1)
  • int64: yes; tested (2)
  • float16: yes; tested (1)
  • float32: yes; tested (1)
  • float64: yes; tested (1)
  • float128: no
  • bool: yes; tested (1)
    1. Handled by cv2. See backend="cv2".
    1. Handled by scipy. See backend="scipy".

if (backend=”cv2”):

  • uint8: yes; fully tested
  • uint16: yes; tested
  • uint32: no (2)
  • uint64: no (3)
  • int8: yes; tested (4)
  • int16: yes; tested
  • int32: yes; tested (5)
  • int64: no (6)
  • float16: yes; tested (7)
  • float32: yes; tested
  • float64: yes; tested
  • float128: no (8)
  • bool: yes; tested (1)
    1. Mapped internally to float32. Otherwise causes TypeError: src data type = 0 is not supported.
    1. Causes TypeError: src data type = 6 is not supported.
    1. Causes cv2.error: OpenCV(3.4.5) (...)/filter.cpp:2957: error: (-213:The function/feature is not implemented) Unsupported combination of source format (=4), and buffer format (=5) in function 'getLinearRowFilter'.
    1. Mapped internally to int16. Otherwise causes cv2.error: OpenCV(3.4.5) (...)/filter.cpp:2957: error: (-213:The function/feature is not implemented) Unsupported combination of source format (=1), and buffer format (=5) in function 'getLinearRowFilter'.
    1. Mapped internally to float64. Otherwise causes cv2.error: OpenCV(3.4.5) (...)/filter.cpp:2957: error: (-213:The function/feature is not implemented) Unsupported combination of source format (=4), and buffer format (=5) in function 'getLinearRowFilter'.
    1. Causes cv2.error: OpenCV(3.4.5) (...)/filter.cpp:2957: error: (-213:The function/feature is not implemented) Unsupported combination of source format (=4), and buffer format (=5) in function 'getLinearRowFilter'.
    1. Mapped internally to float32. Otherwise causes TypeError: src data type = 23 is not supported.
    1. Causes TypeError: src data type = 13 is not supported.

if (backend=”scipy”):

  • uint8: yes; fully tested
  • uint16: yes; tested
  • uint32: yes; tested
  • uint64: yes; tested
  • int8: yes; tested
  • int16: yes; tested
  • int32: yes; tested
  • int64: yes; tested
  • float16: yes; tested (1)
  • float32: yes; tested
  • float64: yes; tested
  • float128: no (2)
  • bool: yes; tested (3)
    1. Mapped internally to float32. Otherwise causes RuntimeError: array type dtype('float16') not supported.
    1. Causes RuntimeError: array type dtype('float128') not supported.
    1. Mapped internally to float32. Otherwise too inaccurate.
Parameters:
  • image (numpy.ndarray) – The image to blur. Expected to be of shape (H, W) or (H, W, C).
  • sigma (number) – Standard deviation of the gaussian blur. Larger numbers result in more large-scale blurring, which is overall slower than small-scale blurring.
  • ksize (None or int, optional) – Size in height/width of the gaussian kernel. This argument is only understood by the cv2 backend. If it is set to None, an appropriate value for ksize will automatically be derived from sigma. The value is chosen tighter for larger sigmas to avoid as much as possible very large kernel sizes and therey improve performance.
  • backend ({‘auto’, ‘cv2’, ‘scipy’}, optional) – Backend library to use. If auto, then the likely best library will be automatically picked per image. That is usually equivalent to cv2 (OpenCV) and it will fall back to scipy for datatypes not supported by OpenCV.
  • eps (number, optional) – A threshold used to decide whether sigma can be considered zero.
Returns:

The blurred image. Same shape and dtype as the input. (Input image might have been altered in-place.)

Return type:

numpy.ndarray

imgaug.augmenters.blur.blur_mean_shift_(image, spatial_window_radius, color_window_radius)[source]

Apply a pyramidic mean shift filter to the input image in-place.

This produces an output image that has similarity with one modified by a bilateral filter. That is different from mean shift segmentation, which averages the colors in segments found by mean shift clustering.

This function is a thin wrapper around cv2.pyrMeanShiftFiltering.

Note

This function does not change the image’s colorspace to RGB before applying the mean shift filter. A non-RGB colorspace will hence influence the results.

Note

This function is quite slow.

Added in 0.4.0.

Supported dtypes:

  • uint8: yes; fully 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. Not supported by cv2.pyrMeanShiftFiltering.
Parameters:
  • image (ndarray) – (H,W) or (H,W,1) or (H,W,3) image to blur. Images with no or one channel will be temporarily tiled to have three channels.
  • spatial_window_radius (number) – Spatial radius for pixels that are assumed to be similar.
  • color_window_radius (number) – Color radius for pixels that are assumed to be similar.
Returns:

Blurred input image. Same shape and dtype as the input. (Input image might have been altered in-place.)

Return type:

ndarray