mindspore.dataset.vision.AutoContrast

class mindspore.dataset.vision.AutoContrast(cutoff=0.0, ignore=None)[source]

Apply automatic contrast on input image. This operation calculates histogram of image, reassign cutoff percent of the lightest pixels from histogram to 255, and reassign cutoff percent of the darkest pixels from histogram to 0.

Parameters
  • cutoff (float, optional) – Percent of lightest and darkest pixels to cut off from the histogram of input image. The value must be in the range [0.0, 50.0]. Default: 0.0.

  • ignore (Union[int, sequence], optional) – The background pixel values to ignore, The ignore values must be in range [0, 255]. Default: None.

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

  • TypeError – If ignore is not of type int or sequence.

  • ValueError – If cutoff is not in range [0, 50.0).

  • ValueError – If ignore is not in range [0, 255].

  • RuntimeError – If given tensor shape is not <H, W> or <H, W, C>.

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> transforms_list = [vision.Decode(), vision.AutoContrast(cutoff=10.0, ignore=[10, 20])]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])
Tutorial Examples: