[][src]Function imageproc::pixelops::weighted_sum

pub fn weighted_sum<P: Pixel>(
    left: P,
    right: P,
    left_weight: f32,
    right_weight: f32
) -> P where
    P::Subpixel: ValueInto<f32> + Clamp<f32>, 

Adds pixels with the given weights. Results are clamped to prevent arithmetical overflows.

Examples

use image::Rgb;
use imageproc::pixelops::weighted_sum;

let left = Rgb([10u8, 20u8, 30u8]);
let right = Rgb([100u8, 80u8, 60u8]);

let sum = weighted_sum(left, right, 0.7, 0.3);
assert_eq!(sum, Rgb([37, 38, 39]));