In-memory heatmap used for the composite output — same algorithm as `write_heatmap` but returns a buffer instead of writing it.
(
reference: &[[f32; 3]],
candidate: &[[f32; 3]],
width: u32,
height: u32,
)
| 508 | /// In-memory heatmap used for the composite output — same algorithm |
| 509 | /// as `write_heatmap` but returns a buffer instead of writing it. |
| 510 | fn make_heatmap_buffer( |
| 511 | reference: &[[f32; 3]], |
| 512 | candidate: &[[f32; 3]], |
| 513 | width: u32, |
| 514 | height: u32, |
| 515 | ) -> RgbImage { |
| 516 | let mut img: RgbImage = ImageBuffer::new(width, height); |
| 517 | for y in 0..height { |
| 518 | for x in 0..width { |
| 519 | let i = (y * width + x) as usize; |
| 520 | let dr = (reference[i][0] - candidate[i][0]).abs(); |
| 521 | let dg = (reference[i][1] - candidate[i][1]).abs(); |
| 522 | let db = (reference[i][2] - candidate[i][2]).abs(); |
| 523 | let mag = dr.max(dg).max(db); |
| 524 | img.put_pixel(x, y, heatmap_color(mag)); |
| 525 | } |
| 526 | } |
| 527 | img |
| 528 | } |