JitterOTFPerturber
- class nrtk.impls.perturb_image.pybsm.jitter_otf_perturber.JitterOTFPerturber(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, s_x: float | None = None, s_y: float | None = None, interp: bool = True, box_alignment_mode: str = 'extent')
Implements image perturbation using jitter and Optical Transfer Function (OTF).
This class applies realistic perturbations to images based on sensor and scenario configurations, leveraging Optical Transfer Function (OTF) modeling through the pyBSM library. Perturbations include jitter effects that simulate real-world distortions in optical imaging systems.
- Attributes:
sensor (PybsmSensor | None): The sensor configuration used to define perturbation parameters. scenario (PybsmScenario | None): Scenario configuration providing environmental context for perturbations. additional_params (dict): Additional configuration options for customizing perturbations.
- Methods:
perturb(image): Applies the jitter-based OTF perturbation to the provided image. get_config(): Returns the configuration for the current instance. from_config(config_dict): Instantiates from a configuration dictionary.
Methods
Instantiates a JitterOTFPerturber from a configuration dictionary.
Returns the current configuration of the JitterOTFPerturber instance.
Provides the default configuration for JitterOTFPerturber instances.
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.
Checks if the necessary dependencies (pyBSM and OpenCV) are available.
- __init__(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, s_x: float | None = None, s_y: float | None = None, interp: bool = True, box_alignment_mode: str = 'extent') None
Initializes the JitterOTFPerturber.
- Parameters:
sensor – pyBSM sensor object.
scenario – pyBSM scenario object
s_x – root-mean-squared jitter amplitudes in the x direction (rad).
s_y – root-mean-squared jitter amplitudes in the y direction (rad).
interp – a boolean determining whether load_database_atmosphere is used with or without interpolation
box_alignment_mode –
Mode for how to handle how bounding boxes change. Should be one of the following options:
extent: a new axis-aligned bounding box that encases the transformed misaligned box extant: a new axis-aligned bounding box that is encased inside the transformed misaligned box median: median between extent and extant
Default value is extent
If both sensor and scenario parameters are not present, then default values will be used for their parameters
If neither s_x, s_y, sensor or scenario parameters are provided, the values of s_x and s_y will be the default of 0.0 as that results in a nadir view.
If sensor and scenario parameters are provided, but not s_x and s_y, the values of s_x and s_y will come from the sensor and scenario objects.
If s_x and s_y are ever provided by the user, those values will be used in the otf caluclattion
- Raises:
ImportError if OpenCV or pyBSM is not found,
install via pip install nrtk[pybsm,graphics] or pip install nrtk[pybsm,headless].
- classmethod from_config(config_dict: dict, merge_default: bool = True) Self
Instantiates a JitterOTFPerturber from a configuration dictionary.
- Args:
config_dict (dict): Configuration dictionary with initialization parameters. merge_default (bool, optional): Whether to merge with default configuration. Defaults to True.
- Returns:
C: An instance of JitterOTFPerturber configured according to config_dict.
- get_config() dict[str, Any]
Returns the current configuration of the JitterOTFPerturber instance.
- Returns:
dict[str, Any]: Configuration dictionary with current settings.
- classmethod get_default_config() dict[str, Any]
Provides the default configuration for JitterOTFPerturber instances.
- Returns:
dict[str, Any]: A dictionary with the default configuration values.
- classmethod is_usable() bool
Checks if the necessary dependencies (pyBSM and OpenCV) are available.
- Returns:
bool: True if both pyBSM and OpenCV are available; False otherwise.
- perturb(image: ndarray, boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, additional_params: dict[str, Any] | None = None) tuple[ndarray, Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]
- Raises:
ValueError if ‘img_gsd’ not present in additional_params