MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / load_rgb_normalized

Function load_rgb_normalized

tools/bloom-diff/src/main.rs:67–80  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

65/// for-byte comparison is what we want. Future work could add an
66/// optional --linear flag for tonemapper-bypassing comparisons.
67fn 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
82fn compute_stats(
83 reference: &[[f32; 3]],

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected