mindspore.dataset.vision.Erase

class mindspore.dataset.vision.Erase(top, left, height, width, value=0, inplace=False)[source]

Erase the input image with given value.

Parameters
  • top (int) – Vertical ordinate of the upper left corner of erased region.

  • left (int) – Horizontal ordinate of the upper left corner of erased region.

  • height (int) – Height of erased region.

  • width (int) – Width of erased region.

  • value (Union[int, Sequence[int, int, int]], optional) – Pixel value used to pad the erased area. Default: 0. If int is provided, it will be used for all RGB channels. If Sequence[int, int, int] is provided, it will be used for R, G, B channels respectively.

  • inplace (bool, optional) – Whether to apply erasing inplace. Default: False.

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> # Use the transform in dataset pipeline mode
>>> data = np.random.randint(0, 255, size=(1, 100, 100, 3)).astype(np.uint8)
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data, ["image"])
>>> transforms_list = [vision.Erase(10,10,10,10)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms_list, input_columns=["image"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["image"].shape, item["image"].dtype)
...     break
(100, 100, 3) uint8
>>>
>>> # Use the transform in eager mode
>>> data = np.array([[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]], dtype=np.uint8).reshape((2, 2, 3))
>>> output = vision.Erase(0, 0, 2, 1)(data)
>>> print(output.shape, output.dtype)
(2, 2, 3) uint8
Tutorial Examples: