RadialDistortionPerturber

class nrtk.impls.perturb_image.generic.radial_distortion_perturber.RadialDistortionPerturber(k: Sequence[float] = [0, 0, 0], color_fill: Sequence[int] | None = [0, 0, 0])

RadialDistortionPerturber applies a radial distortion to an image.

Attributes:
k (Sequence[float]): A list of coefficients used to compute the radial distortion,

should have exactly 3 values. Positive values represent a fisheye or barrel distortion, negative values represent a pincushion distortion.

color_fill (Sequence[int]): Background color fill for RGB image.

Methods:
perturb:

Applies the configured radial distortion to the input image and updates bounding boxes.

__call__:

Invokes the perturb method with the given input image and annotations.

get_config:

Returns the current configuration of the RadialDistortionPerturber instance.

Methods

from_config

Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.

get_config

Returns the current configuration of the RadialDistortionPerturber instance.

get_default_config

Generate and return a default configuration dictionary for this class.

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 whether this class is available for use.

perturb

Applies a radial distortion to an image and adjusts bounding boxes.

__call__(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]

Calls perturb with the given input image.

__init__(k: Sequence[float] = [0, 0, 0], color_fill: Sequence[int] | None = [0, 0, 0]) None

Applies a radial distortion to an image.

Args:

k (Sequence[float]): A list of coefficients used to compute the radial distortion. color_fill (Sequence[int]): Background color fill for RGB image.

Raises:

ValueError: Errors when k does not have exactly 3 values

get_config() dict[str, Any]

Returns the current configuration of the RadialDistortionPerturber instance.

Returns:

dict[str, Any]: Configuration dictionary with current settings.

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 a radial distortion to an image and adjusts bounding boxes.

Args:

image (np.ndarray[Any, Any]): Input image as a numpy array of shape (H, W, C). boxes (Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None): List of

bounding boxes in AxisAlignedBoundingBox format and their corresponding classes.

additional_params: Unused

Returns:

np.ndarray[Any, Any]: Distorted image as numpy array Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]]: Updated bounding boxes