pub fn selective_desaturate(img: &mut PhotonImage, ref_color: Rgb, amt: f32)
Expand description

Selectively desaturate pixel colours which are similar to the reference colour provided.

Similarity between two colours is calculated via the CIE76 formula. Only desaturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm. For example, if a user wishes all pixels that are blue to be desaturated by 0.1, they can selectively specify only the blue pixels to be changed.

Arguments

  • img - A PhotonImage.
  • ref_color - The RGB value of the reference color (to be compared to)
  • amt - The amount of desaturate the colour by.

Example

// For example, to only desaturate the pixels that are similar to the RGB value RGB{20, 40, 60}:
use photon_rs::Rgb;
use photon_rs::channels::selective_desaturate;
use photon_rs::native::open_image;

let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
let mut img = open_image("img.jpg").expect("File should open");
selective_desaturate(&mut img, ref_color, 0.1_f32);