RandomSnow
Targets:
image
volume
Image Types:uint8, float32
Applies a random snow effect to the input image.
This transform simulates snowfall by either bleaching out some pixel values or adding a snow texture to the image, depending on the chosen method.
Arguments
snow_point_rangetuple[float, float]
[0.1,0.3]
Range for the snow point threshold. Both values should be in the (0, 1) range. Default: (0.1, 0.3).
brightness_coefffloat
2.5
Coefficient applied to increase the brightness of pixels below the snow_point threshold. Larger values lead to more pronounced snow effects. Should be > 0. Default: 2.5.
methodbleach | texture
bleach
The snow simulation method to use. Options are:
- "bleach": Uses a simple pixel value thresholding technique.
- "texture": Applies a more realistic snow texture overlay. Default: "texture".
pfloat
0.5
Probability of applying the transform. Default: 0.5.
Examples
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, [100, 100, 3], dtype=np.uint8)
# Default usage (bleach method)
>>> transform = A.RandomSnow(p=1.0)
>>> snowy_image = transform(image=image)["image"]
# Using texture method with custom parameters
>>> transform = A.RandomSnow(
... snow_point_range=(0.2, 0.4),
... brightness_coeff=2.0,
... method="texture",
... p=1.0
... )
>>> snowy_image = transform(image=image)["image"]Notes
- The "bleach" method increases the brightness of pixels above a certain threshold, creating a simple snow effect. This method is faster but may look less realistic.
- The "texture" method creates a more realistic snow effect through the following steps:
- Converts the image to HSV color space for better control over brightness.
- Increases overall image brightness to simulate the reflective nature of snow.
- Generates a snow texture using Gaussian noise, which is then smoothed with a Gaussian filter.
- Applies a depth effect to the snow texture, making it more prominent at the top of the image.
- Blends the snow texture with the original image using alpha compositing.
- Adds a slight blue tint to simulate the cool color of snow.
- Adds random sparkle effects to simulate light reflecting off snow crystals. This method produces a more realistic result but is computationally more expensive.