mindspore.dataset.vision.RandomSolarize
- class mindspore.dataset.vision.RandomSolarize(threshold=(0, 255))[source]
Randomly selects a subrange within the specified threshold range and sets the pixel value within the subrange to (255 - pixel).
- Parameters
threshold (tuple, optional) – Range of random solarize threshold. Default:
(0, 255)
. Threshold values should always be in (min, max) format, where min and max are integers in the range [0, 255], and min <= max. The pixel values belonging to the [min, max] range will be inverted. If min=max, then invert all pixel values greater than or equal min(max).- Raises
TypeError – If threshold is not of type tuple.
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.RandomSolarize(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.RandomSolarize(threshold=(1, 10))(data) >>> print(output.shape, output.dtype) (100, 100, 3) uint8
- Tutorial Examples: