ComposePerturber
- class nrtk.impls.perturb_image.generic.compose_perturber.ComposePerturber(perturbers: list[PerturbImage], box_alignment_mode: str = 'extent')
A class that composes multiple image perturbations by applying a list of perturbers sequentially to an input image.
- Note:
This class has not been tested with perturber factories and is not expected to work with perturber factories.
Methods
Create a ComposePerturber instance from a configuration dictionary.
Get the configuration dictionary of the ComposePerturber instance.
get_default_configGenerate and return a default configuration dictionary for this class.
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.
is_usableCheck whether this class is available for use.
Apply the sequence of perturbers to the input image.
- __init__(perturbers: list[PerturbImage], box_alignment_mode: str = 'extent') None
Initializes the ComposePerturber.
This has not been tested with perturber factories and is not expected to work wit perturber factories.
- Parameters:
perturbers – list of perturbers to apply
- classmethod from_config(config_dict: dict, merge_default: bool = True) Self
Create a ComposePerturber instance from a configuration dictionary.
- Args:
config_dict (dict): Configuration dictionary with perturber details. merge_default (bool): Whether to merge with the default configuration.
- Returns:
ComposePerturber: An instance of ComposePerturber.
- get_config() dict[str, Any]
Get the configuration dictionary of the ComposePerturber instance.
- Returns:
dict[str, Any]: Configuration dictionary containing perturber configurations.
- 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]
Apply the sequence of perturbers to the input image.
- Args:
image (np.ndarray): The input image to perturb. boxes (Optional[Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]]): The bounding boxes for
the input image. This is the single image output from DetectImageObjects.detect_objects
additional_params (Optional[dict[str, Any]]): Additional parameters for perturbation.
- Returns:
np.ndarray: The perturbed image.