Skip to main content

apply_matrix_rgb

Function apply_matrix_rgb 

Source
pub fn apply_matrix_rgb(
    data: &mut [u16],
    matrix: &[[f64; 3]; 3],
    max_value: u16,
)
Expand description

Apply a 3×3 color matrix to an interleaved RGB u16 buffer.

For each pixel [R, G, B] the function computes:

R' = m[0][0]*R + m[0][1]*G + m[0][2]*B
G' = m[1][0]*R + m[1][1]*G + m[1][2]*B
B' = m[2][0]*R + m[2][1]*G + m[2][2]*B

Results are clamped to [0, max_value].

§Performance

The scalar loop is written for compiler auto-vectorization.