Repository navigation
Keep achromatic HSL gradients finite - #132
copybara-service[bot] merged 3 commits into
Conversation
| import numpy as np | ||
|
|
||
|
|
||
| class HslGradientsTest(parameterized.TestCase): |
There was a problem hiding this comment.
Please move these tests under color_conversion_test.py. We already have a color transformation test, so you can put them there, thanks!
There was a problem hiding this comment.
Moved the tests into color_conversion_test.py. All 9 new cases and 20 adjacent tests pass on current master.
378e83c to
52a5c62
Compare
pabloduque0
left a comment
There was a problem hiding this comment.
Left a couple nits, otherwise LGTM
Signed-off-by: Sylvester Kaczmarek <[email protected]>
|
Thanks for the review, Pablo. I addressed both nits in |
…adients PiperOrigin-RevId: 1008326399
|
@sylvesterkaczmarek something went wrong with merging back some changes I did internally with yours. I guess the code was at an old commit, sorry about that. Can you please look at the current code again? I'll then redo a review, see internally what happens and hopefully we'll close the loop on this PR. |
|
Thanks for flagging this, Claudio. I checked current |
c49bd1c
into
google-deepmind:master
Problem
rgb_to_hslmasks achromatic hue/saturation outputs after dividing by the zero colour range. The forward value for a grey pixel is correct, but reverse differentiation produces NaNs, including in the lightness component. Low-precision black/white pixels also need a safe denominator for the inactive saturation branch.Change
Replace inactive denominators before division, preserving the existing achromatic output branches and chromatic formula. This follows the JAX guidance on masked undefined operations.
Validation
dm_pix/_src/color_conversion_test.py. Unchanged production code fails eight cases and passes the chromatic finite-difference control.colorsysfinite differences.git diff --checkpass on the current head.Hue is mathematically undefined on the achromatic axis. The tests preserve the existing constant hue/saturation branches and verify the lightness derivative along the greyscale path; they do not assert a unique full colour-space derivative there.
Python 3.12.14 on macOS arm64 CPU. GPU/TPU and the complete image-processing suite were not run. Channel-axis handling in #125 is separate and unchanged. No epsilon, colour convention, dependency, or public API changes.
Reproduced against
ffb65074b39b67e1a686d1348f2d461c7ff3ab45.