From 81d5b3f6a7fd12b5ba2c857b9087697c0b976097 Mon Sep 17 00:00:00 2001 From: mcDandy Date: Mon, 11 May 2026 23:20:34 +0200 Subject: [PATCH] normalise cielab and oklab to the same scale --- more_math/Parser/UnifiedMathVisitor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/more_math/Parser/UnifiedMathVisitor.py b/more_math/Parser/UnifiedMathVisitor.py index 900071c..d4f9bf8 100644 --- a/more_math/Parser/UnifiedMathVisitor.py +++ b/more_math/Parser/UnifiedMathVisitor.py @@ -3827,8 +3827,7 @@ class UnifiedMathVisitor(MathExprVisitor): r = self._promote_to_tensor((yield ctx.expr(0))).float() g = self._promote_to_tensor((yield ctx.expr(1))).float() b = self._promote_to_tensor((yield ctx.expr(2))).float() - x = self._linear_to_cielab(r, g, b) - return torch.stack((x[..., 0]/100, x[..., 1], x[..., 2]), dim=-1) + return self._linear_to_cielab(r, g, b)/100 def _linear_to_srgb(self, c): return torch.where(c <= 0.0031308, 12.92 * c, 1.055 * torch.pow(c, 1.0 / 2.4) - 0.055) @@ -3893,4 +3892,4 @@ class UnifiedMathVisitor(MathExprVisitor): a = self._promote_to_tensor((yield ctx.expr(1))).float() b = self._promote_to_tensor((yield ctx.expr(2))).float() - return self._cielab_to_rgb(L*100, a, b) \ No newline at end of file + return self._cielab_to_rgb(L*100, a*100, b*100) \ No newline at end of file