CircularApertureOTFPerturber
- class nrtk.impls.perturb_image.pybsm.circular_aperture_otf_perturber.CircularApertureOTFPerturber(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, mtf_wavelengths: Sequence[float] | None = None, mtf_weights: Sequence[float] | None = None, interp: bool = True, box_alignment_mode: str = 'extent')
Applies OTF-based image perturbation using a circular aperture model with sensor and scenario configurations.
The CircularApertureOTFPerturber class uses a circular aperture model to simulate image perturbations, allowing for wavelength-specific and sensor-specific modifications based on the sensor and scenario configurations.
- Attributes:
sensor (PybsmSensor | None): The sensor configuration for the perturbation. scenario (PybsmScenario | None): The scenario configuration used for perturbation. mtf_wavelengths (Sequence[float]): Sequence of wavelengths used in MTF calculations. mtf_weights (Sequence[float]): Sequence of weights associated with each wavelength. D (float): Effective aperture diameter. eta (float): Relative linear obscuration. slant_range (float): Line-of-sight distance between platform and target. ifov (float): Instantaneous field of view of the sensor. interp (bool): Specifies whether to use interpolated atmospheric data.
Methods
Instantiates a CircularApertureOTFPerturber from a configuration dictionary.
Returns the current configuration of the CircularApertureOTFPerturber instance.
Provides the default configuration for CircularApertureOTFPerturber 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.
Applies the circular aperture-based perturbation to the provided image.
- __init__(sensor: PybsmSensor | None = None, scenario: PybsmScenario | None = None, mtf_wavelengths: Sequence[float] | None = None, mtf_weights: Sequence[float] | None = None, interp: bool = True, box_alignment_mode: str = 'extent') None
Initializes the CircularApertureOTFPerturber.
- Parameters:
sensor – pyBSM sensor object
scenario – pyBSM scenario object
mtf_wavelengths – a numpy array of wavelengths (m)
mtf_weights – a numpy array of weights for each wavelength contribution (arb)
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 absent, then default values will be used for their parameters
If none of mtf_wavelengths, mtf_weights, sensor or scenario parameters are provided, the values of mtf_wavelengths and mtf_weights will default to [0.50e-6, 0.66e-6] and [1.0, 1.0] respectively
If sensor and scenario parameters are provided, but not mtf_wavelengths and mtf_weights, the values of mtf_wavelengths and mtf_weights will come from the sensor and scenario objects.
If mtf_wavelengths and mtf_weights are 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]. :raises: ValueError if mtf_wavelengths and mtf_weights are not equal length :raises: ValueError if mtf_wavelengths is empty or mtf_weights is empty
- classmethod from_config(config_dict: dict, merge_default: bool = True) Self
Instantiates a CircularApertureOTFPerturber 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:
An instance of CircularApertureOTFPerturber.
- get_config() dict[str, Any]
Returns the current configuration of the CircularApertureOTFPerturber instance.
- Returns:
dict[str, Any]: Configuration dictionary with current settings.
- classmethod get_default_config() dict[str, Any]
Provides the default configuration for CircularApertureOTFPerturber 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: 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]
Applies the circular aperture-based perturbation to the provided image.
- Args:
image (np.ndarray): The image to be perturbed. boxes (Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]], optional): bounding boxes
for detections in input image
additional_params (dict[str, Any], optional): Additional parameters, including ‘img_gsd’.
- Returns:
np.ndarray: The perturbed image. Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]]: Bounding boxes scaled to perturbed image
shape.
- Raises:
ValueError: If ‘img_gsd’ is not provided in additional_params.