HazePerturber#

class nrtk.impls.perturb_image.environment.HazePerturber(factor: float = 1.0)#

HazePerturber applies haze using Shree Nayar weathering.

Attributes:

factor (float): Strength of haze applied to an 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 HazePerturber 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 haze to an image based on depth_map and sky_color.

__init__(factor: float = 1.0) None#

HazePerturber applies haze to an input image.

Attributes:

factor: Strength of haze applied to an image.

get_config() dict[str, Any]#

Returns the current configuration of the HazePerturber instance.

perturb(*, image: ndarray[Any, Any], boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, depth_map: ndarray[Any, Any] | None = None, sky_color: list[float] | None = None, **kwargs: Any) tuple[ndarray[Any, Any], Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]#

Apply haze to an image based on depth_map and sky_color.

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.

depth_map:

Optional depth map for adding haze. If depth_map is not provided, then a depth map the size of the image with all values equal to 1 will be used.

sky_color:

Sky color to use for weathering. If sky_color is not provided, then an average pixel value will be calculated and used as the sky color.

kwargs:

Additional perturbation keyword arguments (currently unused).

Returns:

Image with haze applied and source bounding boxes.