pub fn single_channel_grayscale(photon_image: &mut PhotonImage, channel: usize)
Expand description

Convert an image to grayscale by setting a pixel’s 3 RGB values to a chosen channel’s value.

Arguments

  • photon_image - A PhotonImage.
  • channel - A usize representing the channel from 0 to 2. O represents the Red channel, 1 the Green channel, and 2 the Blue channel.

Example

To grayscale using only values from the Red channel:

use photon_rs::monochrome::single_channel_grayscale;
use photon_rs::native::open_image;

let mut img = open_image("img.jpg").expect("File should open");
single_channel_grayscale(&mut img, 0_usize);