mindspore.dataset.vision.RandomPosterize

View Source On Gitee
class mindspore.dataset.vision.RandomPosterize(bits=(8, 8))[source]

Reduce the bit depth of the color channels of image with a given probability to create a high contrast and vivid color image.

Reduce the number of bits for each color channel to posterize the input image randomly with a given probability.

Parameters

bits (Union[int, Sequence[int]], optional) – Range of random posterize to compress image. Bits values must be in range of [1,8], and include at least one integer value in the given range. It must be in (min, max) or integer format. If min=max, then it is a single fixed magnitude operation. Default: (8, 8).

Raises
  • TypeError – If bits is not of type integer or sequence of integer.

  • ValueError – If bits is not in range [1, 8].

  • 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.RandomPosterize((6, 8))]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])
Tutorial Examples: