RadialDistortionPerturber#
- class nrtk.impls.perturb_image.optical.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
from_configInstantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
Returns the current configuration of the RadialDistortionPerturber instance.
get_default_configGenerate and return a default configuration dictionary for this class.
get_implsDiscover plugins, skipping any entrypoints that fail to load.
get_type_stringReturns the fully qualified type string of the PerturbImage class or its subclass.
is_usableCheck whether this class is available for use.
Applies a radial distortion to an image and adjusts bounding boxes.
- __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.
- perturb(*, image: ndarray[Any, Any], boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, **_: Any) tuple[ndarray[Any, Any], Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]#
Applies a radial distortion to an image and adjusts bounding boxes.
- Args:
- image:
Input image as a numpy array of shape (H, W, C).
- boxes:
List of bounding boxes in AxisAlignedBoundingBox format and their corresponding classes.
- kwargs:
Additional perturbation keyword arguments (currently unused).
- Returns:
Distorted image as numpy array and updated bounding boxes