SaltAndPepperNoisePerturber
- class nrtk.impls.perturb_image.generic.skimage.random_noise.SaltAndPepperNoisePerturber(rng: np.random.Generator | int | None = None, amount: float = 0.05, salt_vs_pepper: float = 0.5, box_alignment_mode: str = 'extent')
Adds salt & pepper noise to image stimulus.
Methods
from_configInstantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
Returns the current configuration of the SaltAndPepperNoisePerturber instance.
get_default_configGenerate and return a default configuration dictionary for this class.
get_implsDiscover and return a set of classes that implement the calling class.
get_type_stringReturns the fully qualified type string of the PerturbImage class or its subclass.
is_usableChecks if the required skimage module is available.
Return image stimulus with S&P noise.
- __init__(rng: np.random.Generator | int | None = None, amount: float = 0.05, salt_vs_pepper: float = 0.5, box_alignment_mode: str = 'extent') 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: np.ndarray, boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, additional_params: dict[str, Any] | None = None) tuple[np.ndarray, Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]
Return image stimulus with S&P noise.