RandomRotationPerturber#

class nrtk.impls.perturb_image.geometric.random.RandomRotationPerturber(*, limit: float | tuple[float, float] = 0.0, probability: float = 1.0, fill: Sequence[int] | None = None, seed: int | None = None, is_static: bool = False)#

RandomRotationPerturber applies a Rotation transformation from Albumentations.

Attributes:
limit (float | tuple[float, float]):

Maximum rotation angle in degrees.

probability (float):

Probability of applying the rotation 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.

fill (numpy.array):

Background color fill for RGB image.

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 RandomRotationPerturber instance.

get_default_config

Generate and return a default configuration dictionary for this class.

get_impls

Discover plugins, skipping any entrypoints that fail to load.

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

Apply a BasicTransform from Albumentations to an image.

__init__(*, limit: float | tuple[float, float] = 0.0, probability: float = 1.0, fill: Sequence[int] | None = None, seed: int | None = None, is_static: bool = False) None#

RandomRotationPerturber applies a Rotation transformation from Albumentations.

Args:
limit (float | tuple[float, float]):

Maximum rotation angle in degrees. For example, 90.0 value means the image can be rotated by any angle between [-90, 90] degrees and (0.0, 90.0) means the image can be rotated by any angle between [0, 90] degrees. Default value is 0.0, which means no rotation.

probability (float):

Probability of applying the rotation transformation. A value of 1.0 means it will always apply the rotation, while a value of 0.0 means it will never apply the rotation. Default value is 1.0.

fill (numpy.array | None):

Background color fill for RGB image. (0 to 255 for each channel). Default value is a black background ([0, 0, 0]).

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

Raises:
ValueError:

Rotation probability must be between 0.0 and 1.0 inclusive.

ValueError:

Color fill values must be integers between 0 and 255 inclusive.

get_config() dict[str, Any]#

Returns the current configuration of the RandomRotationPerturber instance.