Load an RGB image as normalized linear f32 triples. We operate in gamma-encoded (sRGB byte) space rather than re-linearizing — the reference renderer already wrote sRGB-encoded output, so a byte- for-byte comparison is what we want. Future work could add an optional --linear flag for tonemapper-bypassing comparisons.
(path: &Path)
| 65 | /// for-byte comparison is what we want. Future work could add an |
| 66 | /// optional --linear flag for tonemapper-bypassing comparisons. |
| 67 | fn load_rgb_normalized(path: &Path) -> Result<Vec<[f32; 3]>, String> { |
| 68 | let img = image::open(path).map_err(|e| format!("open {:?}: {e}", path))?; |
| 69 | let rgb = img.to_rgb8(); |
| 70 | Ok(rgb |
| 71 | .pixels() |
| 72 | .map(|p| { |
| 73 | [ |
| 74 | p[0] as f32 / 255.0, |
| 75 | p[1] as f32 / 255.0, |
| 76 | p[2] as f32 / 255.0, |
| 77 | ] |
| 78 | }) |
| 79 | .collect()) |
| 80 | } |
| 81 | |
| 82 | fn compute_stats( |
| 83 | reference: &[[f32; 3]], |