pub fn stretch_contrast(image: &GrayImage, lower: u8, upper: u8) -> GrayImage
Expand description
Linearly stretches the contrast in an image, sending lower
to 0u8
and upper
to 2558u8
.
Is it common to choose upper
and lower
values using image percentiles - see percentile
.
ยงExamples
use imageproc::contrast::stretch_contrast;
let image = gray_image!(
0, 20, 50;
80, 100, 255);
let lower = 20;
let upper = 100;
// Pixel intensities between 20 and 100 are linearly
// scaled so that 20 is mapped to 0 and 100 is mapped to 255.
// Pixel intensities less than 20 are sent to 0 and pixel
// intensities greater than 100 are sent to 255.
let stretched = stretch_contrast(&image, lower, upper);
let expected = gray_image!(
0, 0, 95;
191, 255, 255);
assert_pixels_eq!(stretched, expected);