PybsmPerturber

class nrtk.impls.perturb_image.pybsm.pybsm_perturber.PybsmPerturber(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, reflectance_range: ndarray[Any, Any] = array([0.05, 0.5]), rng_seed: int = 1, **kwargs: Any)

Implements image perturbation using pyBSM sensor and scenario configurations.

The PybsmPerturber class applies realistic perturbations to images by leveraging pyBSM’s simulation functionalities. It takes in a sensor and scenario, along with other optional parameters, to simulate environmental effects on the image.

See https://pybsm.readthedocs.io/en/latest/explanation.html for image formation concepts and parameter details.

Attributes:
sensor (PybsmSensor):

The sensor configuration for the perturbation.

scenario (PybsmScenario):

Scenario settings to apply during the perturbation.

reflectance_range (np.ndarray):

Default reflectance range for image simulation.

Methods

from_config

Instantiates a PybsmPerturber from a configuration dictionary.

get_config

Get current configuration including perturber-specific parameters.

get_default_config

Retrieves the default configuration for PybsmPerturber instances.

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

Check if dependencies are available.

perturb

Apply the OTF-based perturbation to the provided image.

__init__(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, reflectance_range: ndarray[Any, Any] = array([0.05, 0.5]), rng_seed: int = 1, **kwargs: Any) None

Initializes the PybsmPerturber.

Args:
sensor:

pyBSM sensor object.

scenario:

pyBSM scenario object.

reflectance_range:

Array of reflectances that correspond to pixel values.

rng_seed:

integer seed value that will be used for the random number generator.

kwargs:

sensor and/or scenario values to modify.

Raises:
raises ImportError:

If pyBSM is not found, install via pip install nrtk[pybsm].

raises ValueError:

If reflectance_range length != 2

raises ValueError:

If reflectance_range not strictly ascending

__repr__() str

Returns a representation of the perturber including sensor and scenario names.

Returns:
return str:

Representation showing sensor and scenario names.

__str__() str

Returns a string representation combining sensor and scenario names.

Returns:
return str:

Concatenated sensor and scenario names.

classmethod from_config(config_dict: dict[str, Any], merge_default: bool = True) PybsmPerturber

Instantiates a PybsmPerturber from a configuration dictionary.

Args:
config_dict:

Configuration dictionary with initialization parameters.

merge_default:

Whether to merge with default configuration. Defaults to True.

Returns:
return PybsmPerturber:

An instance of PybsmPerturber.

get_config() dict[str, Any]

Get current configuration including perturber-specific parameters.

classmethod get_default_config() dict[str, Any]

Retrieves the default configuration for PybsmPerturber instances.

Returns:
return dict[str, Any]:

A dictionary with the default configuration values.

property params: dict[str, Any]

Retrieves the theta parameters related to the perturbation configuration.

This method retrieves extra configuration details for the PybsmPerturber instance, which may include specific parameters related to the sensor, scenario, or any additional customizations applied during initialization.

Returns:
return dict[str, Any]:

A dictionary containing additional perturbation parameters.