nvidia.dali.experimental.dynamic.noise.salt_and_pepper#

nvidia.dali.experimental.dynamic.noise.salt_and_pepper(input, /, *, batch_size=None, device=None, pepper_val=None, per_channel=None, prob=None, salt_val=None, salt_vs_pepper=None, seed=None, rng=None)#

Applies salt-and-pepper noise to the input.

The shape and data type of the output will match the input.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:

input (Tensor/Batch) – Input to the operator.

Keyword Arguments:
  • pepper_val (float or Tensor/Batch of float, optional) –

    Value of “pepper”.

    If not provided, the pepper value will be -1.0 for floating point types or the minimum value of the input data type otherwise, converted to the data type of the input.

  • per_channel (bool, optional, default = False) –

    Determines whether the noise should be generated for each channel independently.

    If set to True, the noise is generated for each channel independently, resulting in some channels being corrupted and others kept intact. If set to False, the noise is generated once and applied to all channels, so that all channels in a pixel should either be kept intact, take the “pepper” value, or the “salt” value.

    Note: Per-channel noise generation requires the input layout to contain a channels (‘C’) dimension, or be empty. In the case of the layout being empty, channel-last layout is assumed.

  • prob (float or Tensor/Batch of float, optional, default = 0.05) – Probability of an output value to take a salt or pepper value.

  • salt_val (float or Tensor/Batch of float, optional) –

    Value of “salt”.

    If not provided, the salt value will be 1.0 for floating point types or the maximum value of the input data type otherwise, converted to the data type of the input.

  • salt_vs_pepper (float or Tensor/Batch of float, optional, default = 0.5) – Probability of a corrupted output value to take a salt value.

  • rng (RNG, optional) – A random number generator instance. Can be obtained by calling nvidia.dali.experimental.dynamic.random.RNG(seed)(). If not provided, the default RNG is used.