mindspore.dataset.vision.Solarize
- class mindspore.dataset.vision.Solarize(threshold)[source]
Solarize the image by inverting all pixel values within the threshold.
- Parameters
threshold (Union[float, Sequence[float, float]]) – Range of solarize threshold, should always be in (min, max) format, where min and max are integers in range of [0, 255], and min <= max. The pixel values belonging to the [min, max] range will be inverted. If a single value is provided or min=max, then invert all pixel values greater than or equal min(max).
- Raises
TypeError – If threshold is not of type float or Sequence[float, float].
ValueError – If threshold is not in range of [0, 255].
- 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.Solarize(threshold=(10, 100))] >>> 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.random.randint(0, 255, size=(100, 100, 3)).astype(np.uint8) >>> output = vision.Solarize(threshold=(1, 10))(data) >>> print(output.shape, output.dtype) (100, 100, 3) uint8
- Tutorial Examples: