mindspore.dataset.vision.AdjustSharpness

class mindspore.dataset.vision.AdjustSharpness(sharpness_factor)[source]

Adjust the sharpness of the input image.

Parameters

sharpness_factor (float) – How much to adjust the sharpness, must be non negative. 0 gives a blurred image, 1 gives the original image while 2 increases the sharpness by a factor of 2.

Raises
  • TypeError – If sharpness_factor is not of type float.

  • ValueError – If sharpness_factor is less than 0.

  • RuntimeError – If shape of the input image is not <H, W> or <H, W, C>.

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
>>> # create a dataset that reads all files in dataset_dir with 8 threads
>>> data = np.random.randint(0, 255, size=(1, 100, 100, 3)).astype(np.uint8)
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data, ["image"])
>>> transforms_list = [vision.AdjustSharpness(sharpness_factor=2.0)]
>>> 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((3, 4))
>>> output = vision.AdjustSharpness(sharpness_factor=0)(data)
>>> print(output.shape, output.dtype)
(3, 4) uint8
Tutorial Examples: