Skip to content

Commit

Permalink
Fix random shadow intensity (#2124)
Browse files Browse the repository at this point in the history
* Empty-Commit

* Fix in RandomShadow
  • Loading branch information
ternaus authored Nov 8, 2024
1 parent ec9c442 commit 802981d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion albumentations/augmentations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,9 @@ def add_shadow(img: np.ndarray, vertices_list: list[np.ndarray], intensities: np
# Apply shadow to the channels directly
# It could be tempting to convert to HLS and apply the shadow to the L channel, but it creates artifacts
shadowed_indices = mask[:, :, 0] == max_value
darkness = 1 - shadow_intensity
img_shadowed[shadowed_indices] = clip(
img_shadowed[shadowed_indices] * shadow_intensity,
img_shadowed[shadowed_indices] * darkness,
np.uint8,
inplace=True,
)
Expand Down
4 changes: 2 additions & 2 deletions albumentations/augmentations/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,8 +1413,8 @@ class RandomShadow(ImageOnlyTransform):
num_shadows_limit (tuple[int, int]): Lower and upper limits for the possible number of shadows.
Default: (1, 2).
shadow_dimension (int): Number of edges in the shadow polygons. Default: 5.
shadow_intensity_range (tuple[float, float]): Range for the shadow intensity.
Should be two float values between 0 and 1. Default: (0.5, 0.5).
shadow_intensity_range (tuple[float, float]): Range for the shadow intensity. Larger value
means darker shadow. Should be two float values between 0 and 1. Default: (0.5, 0.5).
p (float): Probability of applying the transform. Default: 0.5.
Targets:
Expand Down

0 comments on commit 802981d

Please sign in to comment.