ITADN

test: add XYB color space tests (6 currently failing)

#2Pull Requestlilith 创建于 2025-12-27
L
lilithcommented
## Summary This PR adds comprehensive XYB color space tests that verify the implementation against the JPEG XL specification. **6 out of 7 tests are currently failing**, exposing a critical bug in the XYB implementation. ## Failing Tests | Test | Expected | Actual | |------|----------|--------| | `test_xyb_black_should_be_zero` | Black → XYB(0, 0, 0) | Black → XYB(0.028, 0.485, 0.012) | | `test_xyb_colors_should_be_distinct` | Different colors → different XYB | Black, Green, Blue all → same XYB | | `test_xyb_round_trip_primaries` | RGB → XYB → RGB preserves values | Most colors → (255, 0, 0) or wrong | | `test_xyb_neutral_colors_have_zero_opponents` | Gray → X≈0, B≈0 | Gray → X=0.028 | | `test_xyb_red_green_opponent` | Red X > 0, Green X < 0 | Red X = 0 | | `test_xyb_blue_channel` | Blue B > 0.3 | Blue B = 0.012 | ## Root Cause Analysis The bug pattern suggests a **channel confusion** issue: - Colors with `r=0` (Black, Green, Blue) all produce identical XYB values - These values match what pure Red (255,0,0) should produce - This suggests `from_rgb` or `from_linear_rgb` may only be reading the R channel ## Expected Values (from JPEG XL spec) ``` Red [255, 0, 0] → XYB(+0.028, 0.488, +0.012) Green [ 0,255, 0] → XYB(-0.015, 0.715, -0.293) Blue [ 0, 0,255] → XYB( 0.000, 0.278, +0.388) White [255,255,255] → XYB( 0.000, 0.845, 0.000) Black [ 0, 0, 0] → XYB( 0.000, 0.000, 0.000) Gray [128,128,128] → XYB( 0.000, 0.447, 0.000) ``` ## Test Output ``` running 7 tests test test_xyb_white_known_values ... ok test test_xyb_black_should_be_zero ... FAILED test test_xyb_blue_channel ... FAILED test test_xyb_colors_should_be_distinct ... FAILED test test_xyb_neutral_colors_have_zero_opponents ... FAILED test test_xyb_red_green_opponent ... FAILED test test_xyb_round_trip_primaries ... FAILED test result: FAILED. 1 passed; 6 failed ``` ## What to Check 1. `Rgb::to_linear()` - is the transfer function applied correctly to all channels? 2. `Rgb<f32>` field ordering - are r, g, b fields being accessed correctly? 3. Matrix multiplication in `from_linear_rgb` - are all three channels being used? I'd be happy to help debug further if needed!
合并状态:未合并 关闭于 2025-12-27 1 条评论