RandomScalePerturber#
- class nrtk.impls.perturb_image.geometric.random.RandomScalePerturber(*, limit: float | tuple[float, float] = 0.0, interpolation: int = 1, probability: float = 1.0, seed: int | None = None, is_static: bool = False)#
RandomScalePerturber applies a Scale transformation from Albumentations.
- Attributes:
- limit (float | tuple[float, float]):
Range of scaling factors. A single float value is equivalent to a tuple of (-value, value). One will then be added to each value. Therefore, a given value of (-0.2, 0.1) corresponds to scaling the image between 0.8x and 1.1x, and a given value of 0.5 corresponds to scaling the image between 0.5x and 1.5x.
- interpolation (int)
OpenCV flag indicating the interpolation algorithm.
- probability (float):
Probability of applying the scale transformation.
- seed (int | None):
Random seed for reproducibility. None for non-deterministic behavior.
- is_static (bool):
If True, resets seed after each call for consistent results.
Methods
from_configInstantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
Returns the current configuration of the RandomScalePerturber 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.
perturbApply a BasicTransform from Albumentations to an image.
- __init__(*, limit: float | tuple[float, float] = 0.0, interpolation: int = 1, probability: float = 1.0, seed: int | None = None, is_static: bool = False) None#
RandomScalePerturber applies a random scale perturbation to an input image.
It ensures that bounding boxes are adjusted correctly to reflect the translated image coordinates.
- Args:
- limit:
Range of scaling factors. A single float value is equivalent to a tuple of (-value, value). One will then be added to each value. Therefore, a given value of (-0.2, 0.1) corresponds to scaling the image between 0.8x and 1.1x, and a given value of 0.5 corresponds to scaling the image between 0.5x and 1.5x.
- interpolation:
OpenCV flag indicating the interpolation algorithm.
- probability:
Probability of applying the scale transformation.
- seed:
Random seed for reproducible results. Defaults to None for non-deterministic behavior.
- is_static:
If True and seed is provided, resets seed after each perturb call for consistent results across multiple calls (useful for video frame processing).
- get_config() dict[str, Any]#
Returns the current configuration of the RandomScalePerturber instance.