SaltAndPepperNoisePerturber

class nrtk.impls.perturb_image.generic.skimage.random_noise.SaltAndPepperNoisePerturber(rng: Generator | int | None = None, amount: float = 0.05, salt_vs_pepper: float = 0.5)

Adds salt & pepper noise to image stimulus.

Methods

from_config

Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.

get_config

Returns the current configuration of the SaltAndPepperNoisePerturber instance.

get_default_config

Generate and return a default configuration dictionary for this class.

get_impls

Discover and return a set of classes that implement the calling class.

get_type_string

Returns the fully qualified type string of the PerturbImage class or its subclass.

is_usable

Checks if the required skimage module is available.

perturb

Return image stimulus with S&P noise.

__init__(rng: Generator | int | None = None, amount: float = 0.05, salt_vs_pepper: float = 0.5) None

Initializes the SaltAndPepperNoisePerturber.

Parameters:
  • rng – Pseudo-random number generator or seed.

  • amount – Proportion of image pixels to replace with noise on range [0, 1].

  • salt_vs_pepper – Proportion of salt vs. pepper noise on range [0, 1]. Higher values represent more salt.

get_config() dict[str, Any]

Returns the current configuration of the SaltAndPepperNoisePerturber instance.

Returns:

dict[str, Any]: Configuration dictionary with current settings.

perturb(image: ndarray[Any, Any], boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, additional_params: dict[str, Any] | None = None) tuple[ndarray[Any, Any], Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]

Return image stimulus with S&P noise.