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

Commit 57b1b65

Browse files
committed
Avoid rgb clamping as much as possible
1 parent 8368a37 commit 57b1b65

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
@@ -62,10 +62,6 @@ def apply_RGB_matrix(var1, var2, var3, rgb_type, convtype="xyz_to_rgb"):
6262
# Perform the adaptation via matrix multiplication.
6363
result_matrix = numpy.dot(rgb_matrix, var_matrix)
6464
rgb_r, rgb_g, rgb_b = result_matrix
65-
# Clamp these values to a valid range.
66-
rgb_r = max(rgb_r, 0.0)
67-
rgb_g = max(rgb_g, 0.0)
68-
rgb_b = max(rgb_b, 0.0)
6965
return rgb_r, rgb_g, rgb_b
7066

7167

@@ -555,7 +551,8 @@ def XYZ_to_RGB(cobj, target_rgb, *args, **kwargs):
555551
else:
556552
# If it's not sRGB...
557553
for channel in ["r", "g", "b"]:
558-
v = linear_channels[channel]
554+
# Clamp value to a valid range.
555+
v = max(linear_channels[channel], 0.0)
559556
nonlinear_channels[channel] = math.pow(v, 1 / target_rgb.rgb_gamma)
560557

561558
return target_rgb(

0 commit comments

Comments
 (0)