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)

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.

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

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

from_config

Instantiates a CircularApertureOTFPerturber from a configuration dictionary.

get_config

Returns the current configuration of the CircularApertureOTFPerturber instance.

get_default_config

Retrieves the default configuration for CircularApertureOTFPerturber 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

Checks if the necessary dependencies (pyBSM and OpenCV) are available.

perturb

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) None

Initializes the CircularApertureOTFPerturber.

Args:
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.

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 calculation.

Raises:
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[str, Any], merge_default: bool = True) Self

Instantiates a CircularApertureOTFPerturber 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 CircularApertureOTFPerturber:

An instance of CircularApertureOTFPerturber.

get_config() dict[str, Any]

Returns the current configuration of the CircularApertureOTFPerturber instance.

Returns:
return dict[str, Any]:

Configuration dictionary with current settings.

classmethod get_default_config() dict[str, Any]

Retrieves the default configuration for CircularApertureOTFPerturber instances.

Returns:
return 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:
return bool:

True if both pyBSM and OpenCV are available; False otherwise.

perturb(image: ndarray[Any, Any], boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, additional_params: dict[str, Any] | None = None) tuple[ndarray[Any, Any], Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]

Applies the circular aperture-based perturbation to the provided image.

Args:
image:

The image to be perturbed.

boxes:

Bounding boxes for detections in input image.

additional_params:
Dictionary containing:
  • “img_gsd” (float): GSD is the distance between the centers of two adjacent

pixels in an image, measured on the ground.

Returns:
return tuple[np.ndarray, Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]:

The perturbed image and bounding boxes scaled to perturbed image shape.

Raises:
raises ValueError:

If ‘img_gsd’ is not provided in additional_params.