mindspore.dataset.vision.c_transforms.RandomPosterize

class mindspore.dataset.vision.c_transforms.RandomPosterize(bits=(8, 8))[source]

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

Parameters

bits (sequence or 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

>>> transforms_list = [c_vision.Decode(), c_vision.RandomPosterize((6, 8))]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])