Function replace_background

Source
pub fn replace_background(
    photon_image: &mut PhotonImage,
    img2: &PhotonImage,
    background_color: &Rgb,
)
Expand description

Change the background of an image (using a green screen/color screen).

§Arguments

  • img - A PhotonImage which contains the desired background. Must be the same size as img2.
  • img2 - The image you would like to swap the background of. Must be the same size as img.
  • background_color - The RGB value of the background, which should be replaced.

§Example

// For example, to replace the background of ImageA (which is RGB value 20, 40, 60) with the background of ImageB:
use photon_rs::Rgb;
use photon_rs::multiple::replace_background;
use photon_rs::native::open_image;

let rgb = Rgb::new(20_u8, 40_u8, 60_u8);
let mut img = open_image("img.jpg").expect("File should open");
let img2 = open_image("img2.jpg").expect("File should open");
replace_background(&mut img, &img2, &rgb);