DefocusOTFPerturber
- class nrtk.impls.perturb_image.pybsm.defocus_otf_perturber.DefocusOTFPerturber(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, w_x: float | None = None, w_y: float | None = None, interp: bool = True, box_alignment_mode: str = 'extent')
DefocusOTFPerturber applies optical defocus perturbations to input images based on specified sensor and scenario configurations. The perturbation uses the Optical Transfer Function (OTF) and Point Spread Function (PSF) for simulation.
- Attributes:
sensor (PybsmSensor | None): The sensor configuration for the simulation. scenario (PybsmScenario | None): The scenario configuration, such as altitude and ground range. w_x (float | None): Defocus parameter in the x-direction. w_y (float | None): Defocus parameter in the y-direction. interp (bool): Whether to interpolate atmosphere data. mtf_wavelengths (np.ndarray): Array of wavelengths used for Modulation Transfer Function (MTF). D (float): Lens diameter in meters. slant_range (float): Slant range in meters, calculated from altitude and ground range. ifov (float): Instantaneous Field of View (IFOV).
- Methods:
perturb: Applies the defocus effect to the input image. __call__: Alias for the perturb method. get_default_config: Provides the default configuration for the perturber. from_config: Instantiates the perturber from a configuration dictionary. get_config: Retrieves the current configuration of the perturber instance.
Methods
Instantiates a DefocusOTFPerturber from a configuration dictionary.
Returns the current configuration of the DefocusOTFPerturber instance.
Provides the default configuration for DefocusOTFPerturber 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 is available.
- __init__(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, w_x: float | None = None, w_y: float | None = None, interp: bool = True, box_alignment_mode: str = 'extent') None
Initializes a DefocusOTFPerturber instance with the specified parameters.
- Args:
sensor (PybsmSensor | None): Sensor configuration for the simulation. scenario (PybsmScenario | None): Scenario configuration (altitude, ground range, etc.). w_x (float | None): the 1/e blur spot radii in the x direction. Defaults to the sensor’s value if provided. w_y (float | None): the 1/e blur spot radii in the y direction. Defaults to the sensor’s value if provided. interp (bool): Whether to interpolate atmosphere data. Defaults to True. box_alignment_mode (string) 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
- classmethod from_config(config_dict: dict, merge_default: bool = True) Self
Instantiates a DefocusOTFPerturber 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 DefocusOTFPerturber configured according to config_dict.
- get_config() dict[str, Any]
Returns the current configuration of the DefocusOTFPerturber instance.
- Returns:
dict[str, Any]: Configuration dictionary with current settings.
- classmethod get_default_config() dict[str, Any]
Provides the default configuration for DefocusOTFPerturber instances.
- Returns:
dict[str, Any]: A dictionary with the default configuration values.
- classmethod is_usable() bool
Checks if the necessary dependencies pyBSM is available.
- Returns:
bool: True if pyBSM is 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