Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit 6975d4f

Browse files
committed
Avoid rgb clamping as much as possible
1 parent 0a4275f commit 6975d4f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

colormath/color_conversions.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ def apply_RGB_matrix(var1, var2, var3, rgb_type, convtype="xyz_to_rgb"):
4848
# Perform the adaptation via matrix multiplication.
4949
result_matrix = numpy.dot(rgb_matrix, var_matrix)
5050
rgb_r, rgb_g, rgb_b = result_matrix
51-
# Clamp these values to a valid range.
52-
rgb_r = max(rgb_r, 0.0)
53-
rgb_g = max(rgb_g, 0.0)
54-
rgb_b = max(rgb_b, 0.0)
5551
return rgb_r, rgb_g, rgb_b
5652

5753

@@ -530,7 +526,8 @@ def XYZ_to_RGB(cobj, target_rgb, *args, **kwargs):
530526
else:
531527
# If it's not sRGB...
532528
for channel in ['r', 'g', 'b']:
533-
v = linear_channels[channel]
529+
# Clamp value to a valid range.
530+
v = max(linear_channels[channel], 0.0)
534531
nonlinear_channels[channel] = math.pow(v, 1 / target_rgb.rgb_gamma)
535532

536533
return target_rgb(

0 commit comments

Comments
 (0)