Check for and handle negative values in post_adaptation_non_linear_response_compression_forward()
As per the formulas on pp. 50-51 of
91-c1.pdf.
@@ -699,9 +699,8 @@ def post_adaptation_non_linear_response_compression_forward(RGB, F_L):
RGB = np.asarray(RGB)
F_L = np.asarray(F_L)
- # TODO: Check for negative values and their handling.
- RGB_c = ((((400 * (F_L[..., np.newaxis] * RGB / 100) ** 0.42) /
- (27.13 + (F_L[..., np.newaxis] * RGB / 100) ** 0.42))) + 0.1)
+ F_L_RGB = (F_L[..., np.newaxis] * abs(RGB) / 100) ** 0.42
+ RGB_c = ((400 * np.sign(RGB) * F_L_RGB) / (27.13 + F_L_RGB)) + 0.1
return RGB_c
