Update nodes to work with linear color by default (#1135)

* Update nodes to work with linear color by default

* Make tests work in linear not gamma
This commit is contained in:
Keavon Chambers 2023-04-16 12:20:44 -07:00
parent f68bc42fc9
commit fa23e9d55b
8 changed files with 131 additions and 102 deletions

View file

@ -34,7 +34,7 @@ use document_legacy::layers::text_layer::Font;
use document_legacy::{DocumentError, DocumentResponse, LayerId, Operation as DocumentOperation}; use document_legacy::{DocumentError, DocumentResponse, LayerId, Operation as DocumentOperation};
use graph_craft::document::NodeId; use graph_craft::document::NodeId;
use graph_craft::{concrete, Type, TypeDescriptor}; use graph_craft::{concrete, Type, TypeDescriptor};
use graphene_core::raster::{Color, ImageFrame, RasterMut}; use graphene_core::raster::{Color, ImageFrame};
use graphene_core::Cow; use graphene_core::Cow;
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};

View file

@ -366,32 +366,32 @@ fn static_nodes() -> Vec<DocumentNodeType> {
DocumentInputType { DocumentInputType {
name: "Reds", name: "Reds",
data_type: FrontendGraphDataType::Number, data_type: FrontendGraphDataType::Number,
default: NodeInput::value(TaggedValue::F64(50.), false), default: NodeInput::value(TaggedValue::F64(40.), false),
}, },
DocumentInputType { DocumentInputType {
name: "Yellows", name: "Yellows",
data_type: FrontendGraphDataType::Number, data_type: FrontendGraphDataType::Number,
default: NodeInput::value(TaggedValue::F64(50.), false), default: NodeInput::value(TaggedValue::F64(60.), false),
}, },
DocumentInputType { DocumentInputType {
name: "Greens", name: "Greens",
data_type: FrontendGraphDataType::Number, data_type: FrontendGraphDataType::Number,
default: NodeInput::value(TaggedValue::F64(50.), false), default: NodeInput::value(TaggedValue::F64(40.), false),
}, },
DocumentInputType { DocumentInputType {
name: "Cyans", name: "Cyans",
data_type: FrontendGraphDataType::Number, data_type: FrontendGraphDataType::Number,
default: NodeInput::value(TaggedValue::F64(50.), false), default: NodeInput::value(TaggedValue::F64(60.), false),
}, },
DocumentInputType { DocumentInputType {
name: "Blues", name: "Blues",
data_type: FrontendGraphDataType::Number, data_type: FrontendGraphDataType::Number,
default: NodeInput::value(TaggedValue::F64(50.), false), default: NodeInput::value(TaggedValue::F64(20.), false),
}, },
DocumentInputType { DocumentInputType {
name: "Magentas", name: "Magentas",
data_type: FrontendGraphDataType::Number, data_type: FrontendGraphDataType::Number,
default: NodeInput::value(TaggedValue::F64(50.), false), default: NodeInput::value(TaggedValue::F64(80.), false),
}, },
], ],
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)], outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],

View file

@ -444,7 +444,7 @@ where
#[cfg(target_arch = "spirv")] #[cfg(target_arch = "spirv")]
const NOTHING: () = (); const NOTHING: () = ();
use dyn_any::{DynAny, StaticType, StaticTypeSized}; use dyn_any::{StaticType, StaticTypeSized};
#[derive(Clone, Debug, PartialEq, Copy)] #[derive(Clone, Debug, PartialEq, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct ImageSlice<'a, Pixel> { pub struct ImageSlice<'a, Pixel> {
@ -541,7 +541,7 @@ mod image {
use crate::Node; use crate::Node;
use alloc::vec::Vec; use alloc::vec::Vec;
use core::hash::{Hash, Hasher}; use core::hash::{Hash, Hasher};
use dyn_any::{DynAny, StaticType}; use dyn_any::StaticType;
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]

View file

@ -166,9 +166,6 @@ pub struct LuminanceNode<LuminanceCalculation> {
#[node_macro::node_fn(LuminanceNode)] #[node_macro::node_fn(LuminanceNode)]
fn luminance_color_node(color: Color, luminance_calc: LuminanceCalculation) -> Color { fn luminance_color_node(color: Color, luminance_calc: LuminanceCalculation) -> Color {
// TODO: Remove conversion to linear when the whole node graph uses linear color
let color = color.to_linear_srgb();
let luminance = match luminance_calc { let luminance = match luminance_calc {
LuminanceCalculation::SRGB => color.luminance_srgb(), LuminanceCalculation::SRGB => color.luminance_srgb(),
LuminanceCalculation::Perceptual => color.luminance_perceptual(), LuminanceCalculation::Perceptual => color.luminance_perceptual(),
@ -176,10 +173,6 @@ fn luminance_color_node(color: Color, luminance_calc: LuminanceCalculation) -> C
LuminanceCalculation::MinimumChannels => color.minimum_rgb_channels(), LuminanceCalculation::MinimumChannels => color.minimum_rgb_channels(),
LuminanceCalculation::MaximumChannels => color.maximum_rgb_channels(), LuminanceCalculation::MaximumChannels => color.maximum_rgb_channels(),
}; };
// TODO: Remove conversion to linear when the whole node graph uses linear color
let luminance = Color::linear_to_srgb(luminance);
color.map_rgb(|_| luminance) color.map_rgb(|_| luminance)
} }
@ -195,6 +188,8 @@ pub struct LevelsNode<InputStart, InputMid, InputEnd, OutputStart, OutputEnd> {
// From https://stackoverflow.com/questions/39510072/algorithm-for-adjustment-of-image-levels // From https://stackoverflow.com/questions/39510072/algorithm-for-adjustment-of-image-levels
#[node_macro::node_fn(LevelsNode)] #[node_macro::node_fn(LevelsNode)]
fn levels_node(color: Color, input_start: f64, input_mid: f64, input_end: f64, output_start: f64, output_end: f64) -> Color { fn levels_node(color: Color, input_start: f64, input_mid: f64, input_end: f64, output_start: f64, output_end: f64) -> Color {
let color = color.to_gamma_srgb();
// Input Range (Range: 0-1) // Input Range (Range: 0-1)
let input_shadows = (input_start / 100.) as f32; let input_shadows = (input_start / 100.) as f32;
let input_midtones = (input_mid / 100.) as f32; let input_midtones = (input_mid / 100.) as f32;
@ -230,7 +225,9 @@ fn levels_node(color: Color, input_start: f64, input_mid: f64, input_end: f64, o
let color = color.gamma(gamma); let color = color.gamma(gamma);
// Output levels (Range: 0-1) // Output levels (Range: 0-1)
color.map_rgb(|c| c * (output_maximums - output_minimums) + output_minimums) let color = color.map_rgb(|c| c * (output_maximums - output_minimums) + output_minimums);
color.to_linear_srgb()
} }
#[derive(Debug, Clone, Copy, Default)] #[derive(Debug, Clone, Copy, Default)]
@ -248,6 +245,8 @@ pub struct GrayscaleNode<Tint, Reds, Yellows, Greens, Cyans, Blues, Magentas> {
// Works the same for gamma and linear color // Works the same for gamma and linear color
#[node_macro::node_fn(GrayscaleNode)] #[node_macro::node_fn(GrayscaleNode)]
fn grayscale_color_node(color: Color, tint: Color, reds: f64, yellows: f64, greens: f64, cyans: f64, blues: f64, magentas: f64) -> Color { fn grayscale_color_node(color: Color, tint: Color, reds: f64, yellows: f64, greens: f64, cyans: f64, blues: f64, magentas: f64) -> Color {
let color = color.to_gamma_srgb();
let reds = reds as f32 / 100.; let reds = reds as f32 / 100.;
let yellows = yellows as f32 / 100.; let yellows = yellows as f32 / 100.;
let greens = greens as f32 / 100.; let greens = greens as f32 / 100.;
@ -275,7 +274,9 @@ fn grayscale_color_node(color: Color, tint: Color, reds: f64, yellows: f64, gree
let luminance = gray_base + additional; let luminance = gray_base + additional;
// TODO: Fix "Color" blend mode implementation so it matches the expected behavior perfectly (it's currently close) // TODO: Fix "Color" blend mode implementation so it matches the expected behavior perfectly (it's currently close)
tint.with_luminance(luminance) let color = tint.with_luminance(luminance);
color.to_linear_srgb()
} }
#[cfg(not(target_arch = "spirv"))] #[cfg(not(target_arch = "spirv"))]
@ -295,13 +296,20 @@ mod hue_shift {
#[node_macro::node_fn(HueSaturationNode)] #[node_macro::node_fn(HueSaturationNode)]
fn hue_shift_color_node(color: Color, hue_shift: f64, saturation_shift: f64, lightness_shift: f64) -> Color { fn hue_shift_color_node(color: Color, hue_shift: f64, saturation_shift: f64, lightness_shift: f64) -> Color {
let color = color.to_gamma_srgb();
let [hue, saturation, lightness, alpha] = color.to_hsla(); let [hue, saturation, lightness, alpha] = color.to_hsla();
Color::from_hsla(
let color = Color::from_hsla(
(hue + hue_shift as f32 / 360.) % 1., (hue + hue_shift as f32 / 360.) % 1.,
// TODO: Improve the way saturation works (it's slightly off)
(saturation + saturation_shift as f32 / 100.).clamp(0., 1.), (saturation + saturation_shift as f32 / 100.).clamp(0., 1.),
// TODO: Fix the way lightness works (it's very off)
(lightness + lightness_shift as f32 / 100.).clamp(0., 1.), (lightness + lightness_shift as f32 / 100.).clamp(0., 1.),
alpha, alpha,
) );
color.to_linear_srgb()
} }
} }
@ -310,7 +318,11 @@ pub struct InvertRGBNode;
#[node_macro::node_fn(InvertRGBNode)] #[node_macro::node_fn(InvertRGBNode)]
fn invert_image(color: Color) -> Color { fn invert_image(color: Color) -> Color {
color.map_rgb(|c| color.a() - c) let color = color.to_gamma_srgb();
let color = color.map_rgb(|c| color.a() - c);
color.to_linear_srgb()
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -325,9 +337,6 @@ fn threshold_node(color: Color, min_luminance: f64, max_luminance: f64, luminanc
let min_luminance = Color::srgb_to_linear(min_luminance as f32 / 100.); let min_luminance = Color::srgb_to_linear(min_luminance as f32 / 100.);
let max_luminance = Color::srgb_to_linear(max_luminance as f32 / 100.); let max_luminance = Color::srgb_to_linear(max_luminance as f32 / 100.);
// TODO: Remove conversion to linear when the whole node graph uses linear color
let color = color.to_linear_srgb();
let luminance = match luminance_calc { let luminance = match luminance_calc {
LuminanceCalculation::SRGB => color.luminance_srgb(), LuminanceCalculation::SRGB => color.luminance_srgb(),
LuminanceCalculation::Perceptual => color.luminance_perceptual(), LuminanceCalculation::Perceptual => color.luminance_perceptual(),
@ -358,8 +367,6 @@ fn blend_node(input: (Color, Color), blend_mode: BlendMode, opacity: f64) -> Col
let opacity = opacity / 100.; let opacity = opacity / 100.;
let (foreground, background) = input; let (foreground, background) = input;
let foreground = foreground.to_linear_srgb();
let background = background.to_linear_srgb();
let target_color = match blend_mode { let target_color = match blend_mode {
BlendMode::Normal => background.blend_rgb(foreground, Color::blend_normal), BlendMode::Normal => background.blend_rgb(foreground, Color::blend_normal),
@ -394,10 +401,7 @@ fn blend_node(input: (Color, Color), blend_mode: BlendMode, opacity: f64) -> Col
BlendMode::Luminosity => background.blend_luminosity(foreground), BlendMode::Luminosity => background.blend_luminosity(foreground),
}; };
let multiplied_target_color = target_color.to_associated_alpha(opacity as f32); background.alpha_blend(target_color.to_associated_alpha(opacity as f32))
let blended = background.alpha_blend(multiplied_target_color);
blended.to_gamma_srgb()
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -405,13 +409,10 @@ pub struct VibranceNode<Vibrance> {
vibrance: Vibrance, vibrance: Vibrance,
} }
// From https://stackoverflow.com/questions/33966121/what-is-the-algorithm-for-vibrance-filters // Modified from https://stackoverflow.com/questions/33966121/what-is-the-algorithm-for-vibrance-filters
// The results of this implementation are very close to correct, but not quite perfect // The results of this implementation are very close to correct, but not quite perfect
#[node_macro::node_fn(VibranceNode)] #[node_macro::node_fn(VibranceNode)]
fn vibrance_node(color: Color, vibrance: f64) -> Color { fn vibrance_node(color: Color, vibrance: f64) -> Color {
// TODO: Remove conversion to linear when the whole node graph uses linear color
let color = color.to_linear_srgb();
let vibrance = vibrance as f32 / 100.; let vibrance = vibrance as f32 / 100.;
// Slow the effect down by half when it's negative, since artifacts begin appearing past -50%. // Slow the effect down by half when it's negative, since artifacts begin appearing past -50%.
// So this scales the 0% to -50% range to 0% to -100%. // So this scales the 0% to -50% range to 0% to -100%.
@ -446,7 +447,7 @@ fn vibrance_node(color: Color, vibrance: f64) -> Color {
}; };
let altered_color = altered_color.to_gamma_srgb(); let altered_color = altered_color.to_gamma_srgb();
let altered_color = if vibrance >= 0. { if vibrance >= 0. {
altered_color altered_color
} else { } else {
// TODO: The result ends up a bit darker than it should be, further investigation is needed // TODO: The result ends up a bit darker than it should be, further investigation is needed
@ -456,10 +457,7 @@ fn vibrance_node(color: Color, vibrance: f64) -> Color {
// Near -100% vibrance, we mostly use half the desaturated luminance color and half `altered_color`. // Near -100% vibrance, we mostly use half the desaturated luminance color and half `altered_color`.
let factor = -slowed_vibrance; let factor = -slowed_vibrance;
altered_color.map_rgb(|c| c * (1. - factor) + luminance * factor) altered_color.map_rgb(|c| c * (1. - factor) + luminance * factor)
}; }
// TODO: Remove conversion to linear when the whole node graph uses linear color
altered_color.to_gamma_srgb()
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -479,13 +477,18 @@ pub struct PosterizeNode<P> {
} }
// Based on http://www.axiomx.com/posterize.htm // Based on http://www.axiomx.com/posterize.htm
// This algorithm is perfectly accurate.
#[node_macro::node_fn(PosterizeNode)] #[node_macro::node_fn(PosterizeNode)]
fn posterize(color: Color, posterize_value: f64) -> Color { fn posterize(color: Color, posterize_value: f64) -> Color {
let color = color.to_gamma_srgb();
let posterize_value = posterize_value as f32; let posterize_value = posterize_value as f32;
let number_of_areas = posterize_value.recip(); let number_of_areas = posterize_value.recip();
let size_of_areas = (posterize_value - 1.).recip(); let size_of_areas = (posterize_value - 1.).recip();
let channel = |channel: f32| (channel / number_of_areas).floor() * size_of_areas; let channel = |channel: f32| (channel / number_of_areas).floor() * size_of_areas;
color.map_rgb(channel) let color = color.map_rgb(channel);
color.to_linear_srgb()
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -498,20 +501,15 @@ pub struct ExposureNode<Exposure, Offset, GammaCorrection> {
// Based on https://geraldbakker.nl/psnumbers/exposure.html // Based on https://geraldbakker.nl/psnumbers/exposure.html
#[node_macro::node_fn(ExposureNode)] #[node_macro::node_fn(ExposureNode)]
fn exposure(color: Color, exposure: f64, offset: f64, gamma_correction: f64) -> Color { fn exposure(color: Color, exposure: f64, offset: f64, gamma_correction: f64) -> Color {
// TODO: Remove conversion to linear when the whole node graph uses linear color let adjusted = color
let color = color.to_linear_srgb();
let result = color
// Exposure // Exposure
.map_rgb(|c: f32| c * 2_f32.powf(exposure as f32)) .map_rgb(|c: f32| c * 2_f32.powf(exposure as f32))
// Offset // Offset
.map_rgb(|c: f32| c + offset as f32) .map_rgb(|c: f32| c + offset as f32)
// Gamma correction // Gamma correction
.gamma(gamma_correction as f32) .gamma(gamma_correction as f32);
.map_rgb(|c: f32| c.clamp(0., 1.));
// TODO: Remove conversion to linear when the whole node graph uses linear color adjusted.map_rgb(|c: f32| c.clamp(0., 1.))
result.to_gamma_srgb()
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -11,7 +11,11 @@ impl<'i> Node<'i, Color> for BrightnessContrastLegacyMapperNode {
type Output = Color; type Output = Color;
fn eval<'s: 'i>(&'s self, color: Color) -> Color { fn eval<'s: 'i>(&'s self, color: Color) -> Color {
color.map_rgb(|c| (c + c * self.contrast + self.combined).clamp(0., 1.)) let color = color.to_gamma_srgb();
let color = color.map_rgb(|c| (c + c * self.contrast + self.combined).clamp(0., 1.));
color.to_linear_srgb()
} }
} }
@ -43,10 +47,14 @@ impl<'i> Node<'i, Color> for BrightnessContrastMapperNode {
type Output = Color; type Output = Color;
fn eval<'s: 'i>(&'s self, color: Color) -> Color { fn eval<'s: 'i>(&'s self, color: Color) -> Color {
color.map_rgb(|c| { let color = color.to_gamma_srgb();
let color = color.map_rgb(|c| {
let index_in_combined_lut = (c * (self.combined_lut.len() - 1) as f32).round() as usize; let index_in_combined_lut = (c * (self.combined_lut.len() - 1) as f32).round() as usize;
self.combined_lut[index_in_combined_lut] self.combined_lut[index_in_combined_lut]
}) });
color.to_linear_srgb()
} }
} }
@ -123,20 +131,20 @@ fn solve_cubic_splines(cubic_spline_values: &CubicSplines) -> [f32; 4] {
3. * (y[1] - y[0]) / ((x[1] - x[0]) * (x[1] - x[0])), 3. * (y[1] - y[0]) / ((x[1] - x[0]) * (x[1] - x[0])),
], ],
[ [
1. / (x[1] - x[1 - 1]), 1. / (x[1] - x[0]),
2. * (1. / (x[1] - x[1 - 1]) + 1. / (x[1 + 1] - x[1])), 2. * (1. / (x[1] - x[0]) + 1. / (x[2] - x[1])),
1. / (x[1 + 1] - x[1]), 1. / (x[2] - x[1]),
0., 0.,
// | // |
3. * ((y[1] - y[1 - 1]) / ((x[1] - x[1 - 1]) * (x[1] - x[1 - 1])) + (y[1 + 1] - y[1]) / ((x[1 + 1] - x[1]) * (x[1 + 1] - x[1]))), 3. * ((y[1] - y[0]) / ((x[1] - x[0]) * (x[1] - x[0])) + (y[2] - y[1]) / ((x[2] - x[1]) * (x[2] - x[1]))),
], ],
[ [
0., 0.,
1. / (x[2] - x[2 - 1]), 1. / (x[2] - x[1]),
2. * (1. / (x[2] - x[2 - 1]) + 1. / (x[2 + 1] - x[2])), 2. * (1. / (x[2] - x[1]) + 1. / (x[3] - x[2])),
1. / (x[2 + 1] - x[2]), 1. / (x[3] - x[2]),
// | // |
3. * ((y[2] - y[2 - 1]) / ((x[2] - x[2 - 1]) * (x[2] - x[2 - 1])) + (y[2 + 1] - y[2]) / ((x[2 + 1] - x[2]) * (x[2 + 1] - x[2]))), 3. * ((y[2] - y[1]) / ((x[2] - x[1]) * (x[2] - x[1])) + (y[3] - y[2]) / ((x[3] - x[2]) * (x[3] - x[2]))),
], ],
[ [
0., 0.,
@ -226,10 +234,14 @@ fn interpolate_cubic_splines(input: f32, points: &CubicSplines, solutions: &[f32
} }
mod tests { mod tests {
use crate::value::ClonedNode;
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
#[allow(unused_imports)]
use crate::value::ClonedNode;
fn string_data(string: &str) -> Vec<u8> {
string.split(',').map(|s| s.parse().unwrap()).collect::<Vec<u8>>()
}
#[test] #[test]
fn brightness_contrast_legacy_tests() { fn brightness_contrast_legacy_tests() {
@ -246,34 +258,44 @@ mod tests {
assert_eq!(brightness_contrast_legacy_map(-150., 100.), [0; 256]); assert_eq!(brightness_contrast_legacy_map(-150., 100.), [0; 256]);
assert_eq!(brightness_contrast_legacy_map(-77., 100.), { assert_eq!(brightness_contrast_legacy_map(-77., 100.), {
let mut x = [0; 204].into_iter().chain([77, 178].into_iter()).chain([255; 50].into_iter()); let mut x = [0; 153].into_iter().chain([2, 20, 65, 143].into_iter()).chain([255; 99].into_iter());
core::array::from_fn(|_| x.next().unwrap()) core::array::from_fn(|_| x.next().unwrap())
}); });
assert_eq!(brightness_contrast_legacy_map(0., 100.), { assert_eq!(brightness_contrast_legacy_map(0., 100.), {
let mut x = [0; 127].into_iter().chain([77, 178].into_iter()).chain([255; 127].into_iter()); let mut x = [0; 54].into_iter().chain([13, 107].into_iter()).chain([255; 200].into_iter());
core::array::from_fn(|_| x.next().unwrap()) core::array::from_fn(|_| x.next().unwrap())
}); });
assert_eq!(brightness_contrast_legacy_map(53., 100.), { assert_eq!(brightness_contrast_legacy_map(53., 100.), {
let mut x = [0; 74].into_iter().chain([77, 178].into_iter()).chain([255; 180].into_iter()); let mut x = [0; 18].into_iter().chain([132].into_iter()).chain([255; 237].into_iter());
core::array::from_fn(|_| x.next().unwrap()) core::array::from_fn(|_| x.next().unwrap())
}); });
assert_eq!(brightness_contrast_legacy_map(150., 100.), [255; 256]); assert_eq!(brightness_contrast_legacy_map(150., 100.), [255; 256]);
assert_eq!(brightness_contrast_legacy_map(-150., 0.), { assert_eq!(
let mut x = [0; 151].into_iter().chain(1..); brightness_contrast_legacy_map(-150., 0.),
core::array::from_fn(|_| x.next().unwrap()) [0; 86].into_iter().chain(string_data("1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,11,11,11,11,11,12,12,12,12,13,13,13,13,13,14,14,14,14,15,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,25,25,25,25,26,26,26,27,27,27,27,28,28,28,29,29,29,30,30,30,30,31,31,31,32,32,32,33,33,33,33,34,34,34,35,35,35,36,36")).collect::<Vec<_>>().as_slice(),
}); );
assert_eq!(brightness_contrast_legacy_map(-77., 0.), { assert_eq!(
let mut x = [0; 78].into_iter().chain(1..); brightness_contrast_legacy_map(-77., 0.),
core::array::from_fn(|_| x.next().unwrap()) string_data("0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,6,6,6,6,7,7,7,8,8,8,9,9,9,10,10,11,11,11,12,12,12,13,13,13,14,14,15,15,15,16,16,17,17,17,18,18,19,19,20,20,20,21,21,22,22,23,23,24,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51,51,52,53,53,54,54,55,55,56,56,57,57,58,59,59,60,60,61,61,62,62,63,64,64,65,65,66,66,67,67,68,69,69,70,70,71,71,72,73,73,74,74,75,76,76,77,77,78,78,79,80,80,81,81,82,83,83,84,84,85,85,86,87,87,88,88,89,90,90,91,91,92,93,93,94,94,95,96,96,97,98,98,99,99,100,101,101,102,102,103,104,104,105,105,106,107,107,108,109,109,110,110,111,112,112,113,114").as_slice(),
}); );
assert_eq!(brightness_contrast_legacy_map(0., 0.), core::array::from_fn(|i| i as u8)); assert_eq!(brightness_contrast_legacy_map(0., 0.), core::array::from_fn(|i| i as u8));
assert_eq!(brightness_contrast_legacy_map(53., 0.), core::array::from_fn(|i| (i + 53).min(255) as u8)); assert_eq!(
assert_eq!(brightness_contrast_legacy_map(150., 0.), core::array::from_fn(|i| (i + 150).min(255) as u8)); brightness_contrast_legacy_map(53., 0.),
assert_eq!(brightness_contrast_legacy_map(-150., -100.), [128; 256]); string_data("9,14,18,21,24,27,29,32,34,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,66,68,70,72,73,75,77,79,80,82,84,85,87,89,90,92,94,95,97,99,100,102,104,105,107,108,110,111,113,115,116,118,119,121,122,124,126,127,129,130,132,133,135,136,138,139,141,142,144,145,147,148,150,151,153,154,156,157,159,160,161,163,164,166,167,169,170,172,173,175,176,177,179,180,182,183,185,186,187,189,190,192,193,195,196,197,199,200,202,203,204,206,207,209,210,211,213,214,216,217,218,220,221,223,224,225,227,228,230,231,232,234,235,236,238,239,241,242,243,245,246,247,249,250,251,253,254").into_iter().chain([255; 105].into_iter()).collect::<Vec<_>>().as_slice(),
assert_eq!(brightness_contrast_legacy_map(-77., -100.), [128; 256]); );
assert_eq!(brightness_contrast_legacy_map(0., -100.), [128; 256]); assert_eq!(
assert_eq!(brightness_contrast_legacy_map(53., -100.), [128; 256]); brightness_contrast_legacy_map(150., 0.),
assert_eq!(brightness_contrast_legacy_map(150., -100.), [128; 256]); string_data("78,93,105,114,122,129,135,141,147,152,157,162,167,171,176,180,184,188,192,196,200,204,208,211,215,218,222,225,229,232,236,239,242,245,249,252")
.into_iter()
.chain([255; 220].into_iter())
.collect::<Vec<_>>()
.as_slice(),
);
assert_eq!(brightness_contrast_legacy_map(-150., -100.), [55; 256]);
assert_eq!(brightness_contrast_legacy_map(-77., -100.), [55; 256]);
assert_eq!(brightness_contrast_legacy_map(0., -100.), [55; 256]);
assert_eq!(brightness_contrast_legacy_map(53., -100.), [55; 256]);
assert_eq!(brightness_contrast_legacy_map(150., -100.), [55; 256]);
} }
#[test] #[test]
@ -289,67 +311,65 @@ mod tests {
core::array::from_fn(|x| (mapper.eval(color(x as f32 / 1023.)).r() * 255.).round() as u8) core::array::from_fn(|x| (mapper.eval(color(x as f32 / 1023.)).r() * 255.).round() as u8)
}; };
let string_data = |string: &str| string.split(',').map(|s| s.parse().unwrap()).collect::<Vec<u8>>();
assert_eq!( assert_eq!(
&brightness_contrast_map(-150., 100.), &brightness_contrast_map(-150., 100.),
string_data("0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,38,38,38,38,38,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,41,41,41,41,41,41,42,42,42,42,42,42,42,43,43,43,43,43,43,44,44,44,44,44,45,45,45,45,45,45,45,46,46,46,46,46,46,47,47,47,47,47,48,48,48,48,48,48,48,49,49,49,49,49,50,50,50,50,50,51,51,51,51,51,52,52,52,52,52,53,53,53,53,53,54,54,54,54,54,55,55,55,55,55,56,56,56,56,56,57,57,57,57,57,58,58,58,58,59,59,59,59,59,60,60,60,60,61,61,61,61,61,62,62,62,63,63,63,63,64,64,64,64,65,65,65,65,66,66,66,66,66,67,67,68,68,68,68,69,69,69,69,70,70,70,71,71,71,71,72,72,72,73,73,73,74,74,74,74,75,75,75,76,76,76,77,77,77,78,78,78,79,79,79,80,80,80,81,81,82,82,82,83,83,83,84,84,84,85,85,86,86,86,87,87,88,88,88,89,89,90,90,91,91,92,92,92,93,93,94,94,95,95,96,96,96,97,98,98,99,99,99,100,101,101,101,102,103,103,104,104,105,106,106,107,107,108,108,109,110,110,111,111,112,113,114,114,115,116,116,117,118,119,119,120,121,122,122,123,124,125,125,126,127,128,129,130,131,131,132,133,134,135,136,137,139,140,141,142,143,144,146,147,148,150,151,152,154,155,157,159,160,162,164,166,167,169,171,173,175,177,180,182,184,186,189,191,194,196,199,201,204,206,209,212,214,217,220,223,225,228,231,234,236,239,242,244,247,250,252").as_slice() string_data("0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,31,31,31,31,31,31,32,32,32,32,33,33,33,33,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,36,36,36,37,37,37,37,38,38,38,38,39,39,39,39,40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43,44,44,44,44,45,45,45,45,46,46,47,47,47,47,48,48,49,49,49,49,50,50,50,50,51,51,52,52,52,53,53,53,53,54,54,55,55,56,56,57,57,57,57,58,58,59,59,60,60,61,61,61,62,62,63,63,64,64,65,65,67,67,68,68,69,69,70,70,72,72,72,73,73,74,74,76,76,77,77,79,79,81,81,82,82,82,84,84,86,86,88,88,90,90,92,92,94,94,94,97,97,99,99,101,101,104,104,107,107,110,110,110,113,113,116,116,119,119,123,123,126,126,126,130,130,133,133,137,137,141,141,145,145,145,149,149,154,154,158,158,163,163,163,168,168,172,172,177,177,182,182,182,188,188,193,193,198,198,204,204,204,209,209,215,215,220,220,226,226,226,232,232,237,237,243,243,249,249").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(-77., 100.), brightness_contrast_map(-77., 100.),
string_data("0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,31,31,31,31,31,31,32,32,32,32,32,32,33,33,33,33,33,33,33,34,34,34,34,34,34,35,35,35,35,35,35,36,36,36,36,36,36,37,37,37,37,37,37,38,38,38,38,38,39,39,39,39,39,39,40,40,40,40,40,40,41,41,41,41,42,42,42,42,42,42,43,43,43,43,43,44,44,44,44,45,45,45,45,45,45,46,46,46,46,46,47,47,47,47,48,48,48,48,48,48,49,49,49,49,50,50,50,50,50,51,51,51,51,52,52,52,52,53,53,53,53,53,54,54,54,54,55,55,55,55,56,56,56,56,56,57,57,57,57,58,58,58,58,59,59,59,59,60,60,60,60,60,61,61,61,61,62,62,62,63,63,63,63,64,64,64,64,65,65,65,65,66,66,66,66,67,67,67,68,68,68,68,69,69,69,69,70,70,70,71,71,71,71,72,72,72,72,73,73,73,74,74,74,74,75,75,75,75,76,76,77,77,77,77,78,78,78,78,79,79,79,80,80,80,80,81,81,82,82,82,82,83,83,83,84,84,84,84,85,85,86,86,86,86,87,87,87,88,88,88,88,89,89,90,90,90,90,91,91,92,92,92,92,93,93,93,94,94,94,95,95,95,96,96,96,96,97,97,98,98,99,99,99,99,100,100,101,101,101,101,102,102,103,103,103,103,104,104,105,105,105,106,106,106,107,107,107,108,108,108,109,109,110,110,110,111,111,111,112,112,113,113,113,114,114,114,115,115,116,116,116,117,117,117,118,118,119,119,119,119,120,120,121,121,122,122,122,123,123,124,124,124,125,125,125,126,126,127,127,128,128,128,128,129,129,130,130,131,131,131,131,132,132,133,133,133,134,134,135,135,136,136,136,137,137,138,138,139,139,139,140,140,141,141,142,142,142,143,143,144,144,144,145,145,146,146,147,147,148,148,149,149,150,150,150,151,151,152,152,152,153,153,154,155,155,155,156,156,157,157,157,158,159,159,159,160,160,161,161,161,162,163,163,164,164,164,165,166,166,166,167,167,168,168,169,169,170,170,171,171,172,172,173,173,174,174,175,175,175,176,177,177,177,178,179,179,179,180,180,181,181,182,182,183,183,184,184,185,185,186,186,187,188,188,188,189,189,190,190,191,192,192,193,193,194,194,195,195,195,196,196,197,198,198,199,199,200,200,201,201,202,202,203,204,204,204,205,205,206,207,207,208,208,209,209,210,210,211,211,212,212,213,214,214,214,215,216,216,217,217,218,218,219,219,220,220,221,221,222,222,223,224,224,225,225,226,226,227,227,228,228,229,229,230,230,231,232,232,233,233,234,234,235,235,236,236,237,237,238,238,239,239,240,240,241,241,242,242,243,243,244,244,245,246,246,246,247,247,248,248,249,249,250,250,251,252,252,252,253,253,254,254").as_slice() string_data("0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,25,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27,27,27,27,28,28,28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,31,31,31,31,31,31,31,32,32,32,32,33,33,33,33,33,33,33,34,34,34,34,34,35,35,35,35,36,36,36,36,36,36,36,37,37,37,37,38,38,38,38,38,38,39,39,39,39,40,40,40,40,40,40,41,41,41,41,42,42,42,42,42,42,43,43,43,43,44,44,44,44,44,44,45,45,45,45,46,46,46,46,46,47,47,47,47,47,47,48,48,48,49,49,49,49,50,50,50,50,50,51,51,51,52,52,52,52,52,52,53,53,53,53,53,54,54,54,55,55,55,55,55,55,56,56,56,57,57,57,57,57,57,58,58,58,59,59,59,59,59,60,60,60,61,61,61,62,62,62,62,62,63,63,63,64,64,64,64,65,65,65,65,66,66,66,66,67,67,67,68,68,68,68,68,69,69,69,70,70,70,71,71,71,71,72,72,72,73,73,73,73,73,74,74,74,75,75,76,76,76,77,77,77,77,78,78,78,79,79,79,80,80,80,80,81,81,81,82,82,82,82,83,83,83,84,84,84,85,85,85,85,86,86,86,87,87,88,88,88,88,89,89,89,90,90,90,90,91,92,92,93,93,93,93,94,94,94,95,95,95,95,96,97,97,97,97,98,98,98,98,99,100,100,100,100,101,101,101,101,102,103,103,104,104,104,104,105,105,105,106,106,107,107,107,107,108,108,109,109,109,110,110,111,111,112,112,112,112,113,113,113,114,114,115,115,115,115,117,117,117,117,118,118,118,119,119,120,120,120,120,121,121,122,122,123,123,124,124,124,124,125,126,126,126,126,128,128,128,128,129,129,130,130,130,130,131,131,132,132,133,133,134,134,134,135,135,136,136,137,137,138,138,139,139,139,139,140,140,141,141,142,142,143,143,143,143,144,144,145,145,146,146,147,147,148,148,149,149,149,149,150,150,151,151,152,152,153,153,154,154,155,155,156,156,156,156,158,158,159,159,159,159,160,160,161,161,162,162,163,163,164,164,165,165,166,166,167,167,168,168,169,169,170,170,171,171,171,171,172,172,173,173,174,174,175,175,176,176,177,177,178,178,179,179,180,180,180,181,181,182,182,183,183,184,184,185,185,186,186,187,187,188,188,189,189,190,190,191,191,191,193,193,193,193,194,194,196,196,196,196,198,198,198,198,200,200,201,201,201,202,202,203,203,204,204,205,205,206,206,207,207,208,208,208,209,209,210,210,211,211,212,212,213,213,214,214,214,215,215,217,217,218,218,218,218,220,220,221,221,221,222,222,223,223,224,224,225,225,226,226,226,227,227,228,228,230,230,231,231,232,232,232,233,233,234,234,235,235,236,236,236,237,237,238,238,239,239,240,240,240,242,242,243,243,244,244,245,245,245,246,246,247,247,248,248,249,249,249,250,250,251,251,253,253,254,254").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(0., 100.), brightness_contrast_map(0., 100.),
string_data("0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,16,16,16,16,16,16,16,17,17,17,17,17,17,18,18,18,18,18,18,18,19,19,19,19,19,19,20,20,20,20,20,20,21,21,21,21,21,22,22,22,22,22,22,23,23,23,23,23,24,24,24,24,24,25,25,25,25,25,26,26,26,26,26,27,27,27,27,27,28,28,28,28,28,29,29,29,29,30,30,30,30,30,31,31,31,31,32,32,32,32,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,36,37,37,37,37,38,38,38,39,39,39,39,40,40,40,40,41,41,41,42,42,42,42,43,43,43,44,44,44,45,45,45,45,46,46,46,47,47,47,48,48,48,48,49,49,49,50,50,50,51,51,51,52,52,52,53,53,53,54,54,54,55,55,55,56,56,56,57,57,57,58,58,58,59,59,59,60,60,60,61,61,61,62,62,63,63,63,64,64,64,65,65,65,66,66,66,67,67,68,68,68,69,69,69,70,70,71,71,71,72,72,72,73,73,74,74,74,75,75,75,76,76,77,77,77,78,78,78,79,79,80,80,80,81,81,82,82,82,83,83,84,84,84,85,85,86,86,86,87,87,88,88,88,89,89,90,90,90,91,91,92,92,92,93,93,94,94,94,95,95,96,96,96,97,97,98,98,99,99,99,100,100,101,101,101,102,102,103,103,103,104,104,105,105,106,106,106,107,107,108,108,108,109,109,110,110,111,111,111,112,112,113,113,114,114,114,115,115,116,116,117,117,117,118,118,119,119,119,120,120,121,121,122,122,122,123,123,124,124,125,125,125,126,126,127,127,128,128,128,129,129,130,130,131,131,131,132,132,133,133,133,134,134,135,135,136,136,136,137,137,138,138,139,139,139,140,140,141,141,142,142,142,143,143,144,144,144,145,145,146,146,147,147,147,148,148,149,149,150,150,150,151,151,152,152,152,153,153,154,154,155,155,155,156,156,157,157,157,158,158,159,159,159,160,160,161,161,161,162,162,163,163,164,164,164,165,165,166,166,166,167,167,168,168,168,169,169,170,170,170,171,171,172,172,172,173,173,174,174,174,175,175,175,176,176,177,177,177,178,178,179,179,179,180,180,180,181,181,182,182,182,183,183,183,184,184,185,185,185,186,186,186,187,187,188,188,188,189,189,189,190,190,190,191,191,192,192,192,193,193,193,194,194,194,195,195,195,196,196,196,197,197,198,198,198,199,199,199,200,200,200,201,201,201,202,202,202,203,203,203,204,204,204,204,205,205,205,206,206,206,207,207,207,208,208,208,209,209,209,209,210,210,210,211,211,211,212,212,212,212,213,213,213,214,214,214,214,215,215,215,216,216,216,216,217,217,217,218,218,218,218,219,219,219,219,220,220,220,220,221,221,221,221,222,222,222,222,223,223,223,223,224,224,224,224,225,225,225,225,225,226,226,226,226,227,227,227,227,227,228,228,228,228,229,229,229,229,229,230,230,230,230,230,231,231,231,231,231,232,232,232,232,232,233,233,233,233,233,233,234,234,234,234,234,234,235,235,235,235,235,236,236,236,236,236,236,236,237,237,237,237,237,237,238,238,238,238,238,238,239,239,239,239,239,239,239,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255").as_slice() string_data("0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,11,11,11,11,12,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,16,16,16,16,17,17,17,17,18,18,18,19,19,19,19,20,20,20,21,21,21,22,22,22,22,23,23,23,24,24,24,25,25,25,26,26,26,27,27,27,28,28,28,29,29,29,30,30,30,31,31,31,32,32,33,33,33,34,34,34,35,35,36,36,36,37,37,37,38,38,39,39,39,40,40,41,41,41,42,42,43,43,43,44,44,45,45,45,46,46,46,47,47,48,48,49,49,49,50,50,51,51,52,52,52,53,53,53,54,55,55,55,56,56,57,57,57,58,58,59,59,59,60,60,61,61,62,62,63,63,64,64,65,65,65,66,66,67,67,68,68,68,69,69,70,70,71,71,72,72,73,73,73,74,74,74,75,75,76,76,77,77,78,78,79,79,80,80,81,81,82,82,83,83,83,83,84,84,85,85,86,86,87,87,88,88,88,89,89,90,90,91,92,92,93,93,93,94,94,95,95,96,96,97,97,97,98,98,99,99,100,100,100,101,101,102,102,103,104,104,104,105,105,106,106,107,107,107,108,108,109,109,109,110,111,111,112,112,112,113,113,114,114,115,115,115,116,117,117,117,118,118,119,119,119,120,120,121,121,121,122,123,123,124,124,124,125,125,126,126,126,127,128,128,128,129,129,130,130,130,131,131,131,132,133,133,133,134,134,135,135,135,136,137,137,137,138,138,139,139,139,140,140,140,141,142,142,142,143,143,144,144,144,145,145,145,146,147,147,147,148,148,148,149,149,149,150,150,151,151,152,152,153,153,153,154,154,154,155,155,155,156,156,156,157,158,158,158,159,159,159,160,160,160,161,161,161,162,162,163,163,163,164,164,165,165,165,166,166,166,167,167,168,168,168,169,169,169,170,170,170,171,171,171,172,172,172,173,173,173,174,174,174,175,175,175,176,176,176,177,177,177,178,178,178,179,179,179,180,180,180,180,181,181,181,182,182,182,183,183,183,184,184,184,185,185,185,186,186,186,187,187,187,188,188,188,188,188,189,189,189,190,190,190,191,191,191,191,192,192,192,193,193,193,193,193,194,194,194,195,195,195,196,196,196,196,196,197,197,197,198,198,198,198,198,199,199,199,200,200,200,200,201,201,201,201,201,202,202,202,203,203,203,203,203,204,204,204,204,204,205,205,205,206,206,206,206,206,207,207,207,207,208,208,208,208,208,209,209,209,209,209,210,210,210,210,210,211,211,211,211,211,212,212,212,212,213,213,213,213,213,214,214,214,214,214,215,215,215,215,215,215,216,216,216,216,216,217,217,217,217,217,218,218,218,218,218,218,218,219,219,219,219,219,219,220,220,220,220,220,221,221,221,221,221,221,222,222,222,222,222,222,222,223,223,223,223,223,224,224,224,224,224,224,224,224,225,225,225,225,225,226,226,226,226,226,226,226,226,227,227,227,227,227,227,227,228,228,228,228,228,228,229,229,229,229,229,229,229,230,230,230,230,230,230,230,230,231,231,231,231,231,231,231,231,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,233,233,234,234,234,234,234,234,234,234,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236,237,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(53., 100.), brightness_contrast_map(53., 100.),
string_data("0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,14,15,15,15,15,15,16,16,16,16,16,17,17,17,17,18,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,24,24,24,24,25,25,25,25,26,26,26,27,27,27,27,28,28,28,29,29,29,30,30,30,30,31,31,32,32,32,33,33,33,34,34,34,35,35,35,36,36,36,37,37,37,38,38,39,39,39,40,40,40,41,41,42,42,42,43,43,44,44,45,45,45,46,46,47,47,48,48,48,49,49,50,50,51,51,51,52,52,53,53,54,54,55,55,56,56,57,57,57,58,58,59,59,60,60,61,61,62,62,63,63,64,64,65,65,66,66,66,67,68,68,69,69,69,70,71,71,72,72,73,73,74,74,75,75,76,76,77,77,78,78,79,79,80,80,81,81,82,82,83,84,84,84,85,86,86,87,87,88,88,89,89,90,90,91,92,92,92,93,94,94,95,95,96,96,97,97,98,99,99,100,100,101,101,102,102,103,103,104,104,105,106,106,107,107,108,108,109,109,110,111,111,111,112,113,113,114,114,115,115,116,117,117,118,118,119,119,120,120,121,122,122,122,123,124,124,125,125,126,126,127,128,128,128,129,130,130,131,131,132,132,133,133,134,134,135,136,136,136,137,138,138,139,139,140,140,141,142,142,142,143,144,144,144,145,146,146,147,147,147,148,149,149,150,150,151,151,152,152,153,153,154,155,155,155,156,156,157,157,158,158,159,159,160,160,161,161,162,162,163,163,164,164,165,165,166,166,167,167,168,168,169,169,170,170,170,171,172,172,172,173,174,174,174,175,175,175,176,177,177,177,178,179,179,179,180,180,180,181,182,182,182,183,183,184,184,185,185,185,186,186,187,187,188,188,188,189,189,190,190,190,191,191,192,192,193,193,193,194,194,194,195,195,196,196,196,197,197,198,198,199,199,199,200,200,200,201,201,201,202,202,203,203,203,204,204,204,204,205,205,206,206,206,207,207,207,208,208,208,209,209,209,210,210,210,211,211,211,212,212,212,212,213,213,213,214,214,214,215,215,215,216,216,216,216,217,217,217,218,218,218,218,219,219,219,219,220,220,220,220,221,221,221,221,222,222,222,222,223,223,223,223,224,224,224,224,225,225,225,225,225,226,226,226,226,227,227,227,227,227,228,228,228,228,229,229,229,229,229,230,230,230,230,230,230,231,231,231,231,231,232,232,232,232,232,233,233,233,233,233,233,233,234,234,234,234,234,234,234,235,235,235,235,235,236,236,236,236,236,236,236,236,237,237,237,237,237,237,237,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice() string_data("0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,10,10,11,11,12,12,12,13,13,14,15,15,16,16,17,17,18,19,19,19,20,21,22,22,23,23,24,25,25,26,27,27,28,29,29,30,31,31,32,33,34,34,35,36,36,37,38,39,40,40,41,42,43,43,44,45,46,46,47,48,49,50,50,51,52,53,53,55,55,56,57,57,59,59,60,61,62,63,63,65,65,66,67,68,68,69,70,71,72,73,73,74,75,76,77,77,79,79,80,81,82,83,83,84,85,86,86,87,88,89,90,90,92,93,93,94,95,96,96,98,98,99,99,101,101,102,102,104,105,105,106,107,108,108,109,110,111,112,112,113,114,115,115,116,117,118,119,119,120,120,121,123,123,124,124,125,126,126,128,128,129,129,130,131,131,132,133,134,135,135,136,137,137,138,138,139,140,141,142,142,143,143,144,145,145,146,147,147,148,148,149,149,150,152,152,153,153,154,154,155,155,156,157,158,158,159,159,160,160,161,161,162,162,163,164,165,165,166,166,167,167,168,168,168,169,169,170,170,171,171,172,173,173,174,174,175,175,176,176,177,177,177,178,178,179,179,180,180,181,181,182,182,183,183,183,184,184,185,185,186,186,187,187,187,188,188,188,189,189,190,190,191,191,191,192,192,193,193,193,193,194,194,195,195,196,196,196,196,197,197,198,198,198,198,199,199,200,200,201,201,201,201,201,202,202,202,203,203,203,204,204,204,204,205,205,206,206,206,206,207,207,207,207,208,208,208,208,209,209,209,210,210,210,210,210,211,211,211,211,212,212,212,213,213,213,213,213,214,214,214,214,215,215,215,215,216,216,216,216,216,217,217,217,217,218,218,218,218,218,218,218,219,219,219,219,219,220,220,220,220,221,221,221,221,221,221,222,222,222,222,222,222,222,223,223,223,223,224,224,224,224,224,224,224,225,225,225,225,225,226,226,226,226,226,226,226,227,227,227,227,227,227,227,227,228,228,228,228,228,229,229,229,229,229,229,229,229,229,230,230,230,230,230,230,230,231,231,231,231,231,231,231,231,232,232,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,233,233,234,234,234,234,234,234,234,234,234,234,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236,236,237,237,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(150., 100.), brightness_contrast_map(150., 100.),
string_data("0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,10,10,10,10,11,11,11,12,12,12,13,13,13,14,14,14,15,15,16,16,16,17,17,18,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,30,30,31,31,32,33,33,34,35,35,36,37,37,38,39,40,40,41,42,42,43,44,45,46,46,47,48,49,50,50,51,52,53,54,55,56,56,57,58,59,60,61,62,63,64,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,78,80,80,82,82,84,84,86,86,88,88,90,90,92,92,93,94,95,96,97,99,99,101,101,102,103,104,106,106,107,108,109,111,111,112,114,114,116,117,117,119,119,120,122,122,123,125,125,127,128,128,129,131,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,150,152,152,153,154,155,156,157,158,159,159,161,161,162,163,164,165,166,167,168,168,169,170,171,172,173,174,174,175,176,177,177,178,179,180,180,181,182,183,183,184,185,186,187,188,188,189,189,190,191,192,192,193,194,194,195,196,196,197,198,199,199,200,200,201,202,202,203,204,204,205,205,206,206,207,208,208,209,209,210,210,211,211,212,212,213,213,214,214,215,215,216,216,217,217,218,218,219,219,220,220,220,221,221,222,222,222,223,223,224,224,224,225,225,225,226,226,226,227,227,227,228,228,229,229,229,229,230,230,230,231,231,231,231,232,232,232,233,233,233,233,233,234,234,234,234,235,235,235,235,236,236,236,236,236,237,237,237,237,237,238,238,238,238,238,239,239,239,239,239,239,240,240,240,240,240,240,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice() string_data("0,0,0,1,1,1,2,2,3,4,5,6,7,9,10,12,14,16,18,20,22,25,28,30,33,36,38,41,44,47,50,53,56,59,62,65,68,71,74,77,81,84,87,90,94,96,99,102,105,108,112,114,117,119,123,125,128,130,133,135,138,140,143,146,148,150,152,154,157,159,161,163,165,167,169,170,172,174,176,177,179,181,182,184,186,187,188,189,191,192,193,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,209,210,211,211,213,214,214,215,215,216,216,217,218,218,219,219,220,221,221,222,222,222,223,224,224,224,225,225,226,226,226,227,227,228,228,228,229,229,230,230,230,231,231,231,232,232,232,232,233,233,233,233,233,234,234,234,235,235,235,235,236,236,236,236,236,237,237,237,237,238,238,238,238,238,238,239,239,239,239,239,239,239,240,240,240,240,240,240,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(-150., 0.), brightness_contrast_map(-150., 0.),
string_data("0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,77,77,77,77,77,77,77,78,78,78,78,78,78,79,79,79,79,79,79,79,80,80,80,80,80,80,80,81,81,81,81,81,81,82,82,82,82,82,82,82,83,83,83,83,83,83,84,84,84,84,84,84,85,85,85,85,85,85,85,85,86,86,86,86,86,86,87,87,87,87,87,87,88,88,88,88,88,89,89,89,89,89,89,90,90,90,90,90,91,91,91,91,91,91,92,92,92,92,92,93,93,93,93,93,94,94,94,94,94,95,95,95,95,95,96,96,96,96,96,97,97,97,97,98,98,98,98,98,99,99,99,99,100,100,100,100,101,101,101,101,101,102,102,102,102,103,103,103,103,104,104,104,104,105,105,105,106,106,106,106,107,107,107,107,108,108,108,109,109,109,109,110,110,110,111,111,111,112,112,112,113,113,113,114,114,114,115,115,115,116,116,116,117,117,117,118,118,119,119,119,120,120,121,121,121,122,122,123,123,124,124,125,125,125,126,126,127,127,128,128,129,129,130,130,131,132,132,133,133,134,135,135,136,137,138,138,139,140,141,142,142,143,144,145,146,147,148,149,150,151,153,154,155,157,158,159,161,162,164,166,167,169,170,172,174,176,178,180,183,185,187,190,193,196,199,202,206,210,214,219,224,231,238,246").as_slice() string_data("0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,42,42,42,42,42,42,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,45,45,45,45,45,45,46,46,46,46,46,46,47,47,47,47,47,47,48,48,48,48,48,48,49,49,49,49,50,50,50,50,50,50,51,51,51,51,52,52,52,52,52,52,53,53,53,53,53,54,54,54,54,54,54,55,55,55,55,56,56,56,56,57,57,57,57,58,58,58,58,58,59,59,60,60,60,60,61,61,62,62,62,62,63,63,64,64,64,64,64,65,65,66,66,67,67,67,67,69,69,69,69,70,70,70,71,71,72,72,73,73,74,74,76,76,77,77,77,78,78,79,79,81,81,82,82,84,84,85,85,85,87,87,89,89,91,91,92,92,94,94,94,97,97,99,99,101,101,103,103,106,106,106,108,108,111,111,114,114,117,117,117,120,120,124,124,127,127,131,131,131,135,135,140,140,145,145,151,151,151,157,157,164,164,172,172,180,180,180,191,191,203,203,218,218,235,235").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(-77., 0.), brightness_contrast_map(-77., 0.),
string_data("0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,13,13,13,13,14,14,14,14,14,14,14,15,15,15,15,15,15,16,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,19,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21,21,21,22,22,22,22,22,22,22,23,23,23,23,23,23,24,24,24,24,24,24,24,25,25,25,25,25,25,25,26,26,26,26,26,26,26,27,27,27,27,27,27,28,28,28,28,28,28,28,29,29,29,29,29,29,29,30,30,30,30,30,30,31,31,31,31,31,31,31,32,32,32,32,32,32,32,33,33,33,33,33,33,34,34,34,34,34,34,34,35,35,35,35,35,35,36,36,36,36,36,36,36,37,37,37,37,37,37,37,38,38,38,38,38,38,39,39,39,39,39,39,39,40,40,40,40,40,40,41,41,41,41,41,41,41,42,42,42,42,42,42,43,43,43,43,43,43,43,44,44,44,44,44,44,45,45,45,45,45,45,45,46,46,46,46,46,46,47,47,47,47,47,47,47,48,48,48,48,48,48,49,49,49,49,49,49,49,50,50,50,50,50,50,51,51,51,51,51,51,52,52,52,52,52,52,52,53,53,53,53,53,53,54,54,54,54,54,54,55,55,55,55,55,55,55,56,56,56,56,56,56,57,57,57,57,57,57,58,58,58,58,58,58,58,59,59,59,59,59,59,60,60,60,60,60,60,61,61,61,61,61,61,62,62,62,62,62,62,63,63,63,63,63,63,63,64,64,64,64,64,64,65,65,65,65,65,65,66,66,66,66,66,66,67,67,67,67,67,67,68,68,68,68,68,68,69,69,69,69,69,69,70,70,70,70,70,70,71,71,71,71,71,71,72,72,72,72,72,72,73,73,73,73,73,73,74,74,74,74,74,74,75,75,75,75,75,75,76,76,76,76,76,76,77,77,77,77,77,77,78,78,78,78,78,78,79,79,79,79,79,80,80,80,80,80,80,81,81,81,81,81,81,82,82,82,82,82,82,83,83,83,83,83,84,84,84,84,84,84,85,85,85,85,85,85,85,86,86,86,86,86,86,87,87,87,87,87,88,88,88,88,88,88,89,89,89,89,89,90,90,90,90,90,90,91,91,91,91,91,92,92,92,92,92,92,93,93,93,93,93,94,94,94,94,94,94,95,95,95,95,95,96,96,96,96,96,97,97,97,97,97,97,98,98,98,98,98,99,99,99,99,99,100,100,100,100,100,101,101,101,101,101,101,102,102,102,102,102,103,103,103,103,103,104,104,104,104,104,105,105,105,105,105,106,106,106,106,106,107,107,107,107,107,108,108,108,108,108,109,109,109,109,109,110,110,110,110,110,111,111,111,111,112,112,112,112,112,113,113,113,113,113,114,114,114,114,114,115,115,115,115,116,116,116,116,116,117,117,117,117,117,118,118,118,118,119,119,119,119,119,120,120,120,120,121,121,121,121,121,122,122,122,122,123,123,123,123,123,124,124,124,124,125,125,125,125,126,126,126,126,126,127,127,127,127,128,128,128,128,128,129,129,129,129,129,130,130,130,130,131,131,131,131,132,132,132,132,133,133,133,133,134,134,134,134,135,135,135,135,136,136,136,136,137,137,137,137,138,138,138,138,139,139,139,140,140,140,140,141,141,141,141,142,142,142,142,143,143,143,144,144,144,144,145,145,145,145,146,146,146,147,147,147,147,148,148,148,149,149,149,149,150,150,150,151,151,151,151,152,152,152,153,153,153,154,154,154,154,155,155,155,156,156,156,157,157,157,158,158,158,159,159,159,160,160,160,160,161,161,161,162,162,162,163,163,163,164,164,165,165,165,166,166,166,167,167,167,168,168,168,169,169,170,170,170,170,171,171,171,172,172,173,173,173,174,174,175,175,175,176,176,177,177,177,178,178,179,179,180,180,180,181,181,182,182,183,183,184,184,184,185,185,186,186,187,187,188,188,189,189,190,190,191,191,192,192,193,194,194,195,195,196,196,197,198,198,199,200,200,201,201,202,203,203,204,205,206,206,207,208,209,209,210,211,212,213,214,214,215,216,217,218,219,220,221,222,223,224,226,227,228,229,230,232,233,234,236,237,239,240,242,243,245,246,248,250,251,253").as_slice() string_data("0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,57,57,57,57,57,57,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,60,60,60,60,60,60,61,61,61,61,61,61,61,62,62,62,62,62,62,63,63,63,63,63,63,63,64,64,64,64,64,64,65,65,65,65,65,65,65,66,66,66,66,66,67,67,67,67,67,67,67,68,68,68,68,68,69,69,69,69,69,69,70,70,70,70,70,70,71,71,71,71,71,71,72,72,72,72,72,72,73,73,73,73,73,74,74,74,74,74,74,74,75,75,75,75,75,76,76,76,76,76,77,77,77,77,77,77,78,78,78,78,78,79,79,79,79,79,80,80,80,80,80,80,81,81,81,82,82,82,82,82,82,82,82,83,83,83,84,84,84,84,84,84,85,85,85,85,85,86,86,86,86,87,87,87,87,87,88,88,88,88,88,88,89,89,89,89,90,90,90,91,91,91,91,91,91,92,92,92,92,92,92,93,93,93,93,94,94,94,95,95,95,95,96,96,96,96,97,97,97,97,98,98,98,98,98,98,99,99,99,100,100,100,100,101,101,101,101,102,102,102,102,103,103,103,103,104,104,104,104,105,105,105,105,106,106,106,106,107,107,107,107,108,108,108,108,109,109,109,109,110,110,111,111,111,111,112,112,112,112,113,113,113,113,114,114,115,115,115,115,116,116,116,116,117,117,118,118,119,119,119,119,120,120,120,120,121,121,122,122,123,123,123,123,124,124,124,124,125,125,126,126,127,127,127,127,128,128,129,129,130,130,130,130,130,131,131,132,132,133,133,134,134,134,134,135,135,136,136,137,137,138,138,139,139,139,140,140,141,141,141,141,143,143,143,143,145,145,145,145,147,147,148,148,148,149,149,150,150,151,151,152,152,153,153,154,154,156,156,156,157,157,158,158,159,159,161,161,162,162,163,163,163,165,165,166,166,168,168,169,169,171,171,172,172,172,174,174,176,176,177,177,179,179,181,181,181,183,183,185,185,187,187,189,189,191,191,191,193,193,196,196,198,198,200,200,200,202,202,205,205,208,208,210,210,210,213,213,216,216,219,219,222,222,222,225,225,229,229,232,232,236,236,236,239,239,243,243,247,247,250,250").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(0., 0.), brightness_contrast_map(0., 0.),
string_data("0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30,31,31,31,31,32,32,32,32,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,36,37,37,37,37,38,38,38,38,39,39,39,39,40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43,44,44,44,44,45,45,45,45,46,46,46,46,47,47,47,47,48,48,48,48,49,49,49,49,50,50,50,50,51,51,51,51,52,52,52,52,53,53,53,53,54,54,54,54,55,55,55,55,56,56,56,56,57,57,57,57,58,58,58,58,59,59,59,59,60,60,60,60,61,61,61,61,62,62,62,62,63,63,63,63,64,64,64,64,65,65,65,65,66,66,66,66,67,67,67,67,68,68,68,68,69,69,69,69,70,70,70,70,71,71,71,71,72,72,72,72,73,73,73,73,74,74,74,74,75,75,75,75,76,76,76,76,77,77,77,77,78,78,78,78,79,79,79,79,80,80,80,80,81,81,81,81,82,82,82,82,83,83,83,83,84,84,84,84,85,85,85,85,85,86,86,86,86,87,87,87,87,88,88,88,88,89,89,89,89,90,90,90,90,91,91,91,91,92,92,92,92,93,93,93,93,94,94,94,94,95,95,95,95,96,96,96,96,97,97,97,97,98,98,98,98,99,99,99,99,100,100,100,100,101,101,101,101,102,102,102,102,103,103,103,103,104,104,104,104,105,105,105,105,106,106,106,106,107,107,107,107,108,108,108,108,109,109,109,109,110,110,110,110,111,111,111,111,112,112,112,112,113,113,113,113,114,114,114,114,115,115,115,115,116,116,116,116,117,117,117,117,118,118,118,118,119,119,119,119,120,120,120,120,121,121,121,121,122,122,122,122,123,123,123,123,124,124,124,124,125,125,125,125,126,126,126,126,127,127,127,127,128,128,128,128,129,129,129,129,130,130,130,130,131,131,131,131,132,132,132,132,133,133,133,133,134,134,134,134,135,135,135,135,136,136,136,136,137,137,137,137,138,138,138,138,139,139,139,139,140,140,140,140,141,141,141,141,142,142,142,142,143,143,143,143,144,144,144,144,145,145,145,145,146,146,146,146,147,147,147,147,148,148,148,148,149,149,149,149,150,150,150,150,151,151,151,151,152,152,152,152,153,153,153,153,154,154,154,154,155,155,155,155,156,156,156,156,157,157,157,157,158,158,158,158,159,159,159,159,160,160,160,160,161,161,161,161,162,162,162,162,163,163,163,163,164,164,164,164,165,165,165,165,166,166,166,166,167,167,167,167,168,168,168,168,169,169,169,169,170,170,170,170,170,171,171,171,171,172,172,172,172,173,173,173,173,174,174,174,174,175,175,175,175,176,176,176,176,177,177,177,177,178,178,178,178,179,179,179,179,180,180,180,180,181,181,181,181,182,182,182,182,183,183,183,183,184,184,184,184,185,185,185,185,186,186,186,186,187,187,187,187,188,188,188,188,189,189,189,189,190,190,190,190,191,191,191,191,192,192,192,192,193,193,193,193,194,194,194,194,195,195,195,195,196,196,196,196,197,197,197,197,198,198,198,198,199,199,199,199,200,200,200,200,201,201,201,201,202,202,202,202,203,203,203,203,204,204,204,204,205,205,205,205,206,206,206,206,207,207,207,207,208,208,208,208,209,209,209,209,210,210,210,210,211,211,211,211,212,212,212,212,213,213,213,213,214,214,214,214,215,215,215,215,216,216,216,216,217,217,217,217,218,218,218,218,219,219,219,219,220,220,220,220,221,221,221,221,222,222,222,222,223,223,223,223,224,224,224,224,225,225,225,225,226,226,226,226,227,227,227,227,228,228,228,228,229,229,229,229,230,230,230,230,231,231,231,231,232,232,232,232,233,233,233,233,234,234,234,234,235,235,235,235,236,236,236,236,237,237,237,237,238,238,238,238,239,239,239,239,240,240,240,240,241,241,241,241,242,242,242,242,243,243,243,243,244,244,244,244,245,245,245,245,246,246,246,246,247,247,247,247,248,248,248,248,249,249,249,249,250,250,250,250,251,251,251,251,252,252,252,252,253,253,253,253,254,254,254,254,255,255,255").as_slice() string_data("0,0,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,13,13,13,13,14,14,14,14,14,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30,31,31,31,31,32,32,32,32,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,36,37,37,37,37,38,38,38,38,39,39,39,39,40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43,44,44,44,44,45,45,45,45,46,46,46,46,47,47,47,47,48,48,48,48,49,49,49,49,50,50,50,50,51,51,51,51,52,52,52,52,53,53,53,53,54,54,54,54,55,55,55,55,56,56,56,56,57,57,57,57,58,58,58,58,58,59,59,59,60,60,60,60,61,61,61,61,62,62,62,62,63,63,63,63,64,64,64,64,65,65,65,65,66,66,66,66,66,67,67,67,67,68,68,68,69,69,69,69,70,70,70,70,71,71,71,71,71,72,72,72,73,73,73,73,74,74,74,74,74,75,75,75,76,76,76,76,76,77,77,77,78,78,78,78,78,79,79,79,80,80,80,80,80,81,81,81,82,82,82,82,82,83,83,83,84,84,84,84,85,85,85,85,85,86,86,86,87,87,87,87,88,88,88,88,88,89,89,89,89,90,90,90,91,91,91,91,92,92,92,92,92,93,93,93,93,94,94,94,94,95,95,95,95,96,96,96,97,97,97,97,98,98,98,98,99,99,99,99,100,100,100,100,101,101,101,101,102,102,102,102,103,103,103,103,104,104,104,104,105,105,105,105,106,106,106,106,107,107,107,107,108,108,108,108,108,109,109,109,109,110,110,110,110,111,111,111,111,112,112,112,112,113,113,113,113,113,114,114,115,115,115,115,115,116,116,116,116,117,117,117,117,118,118,118,119,119,119,119,119,120,120,120,120,121,121,121,121,122,122,122,123,123,123,123,123,124,124,124,124,125,125,125,126,126,126,126,126,127,127,127,127,128,128,128,129,129,129,129,129,130,130,130,130,130,131,131,131,132,132,132,132,133,133,133,134,134,134,134,134,135,135,135,135,135,136,136,136,137,137,137,137,137,138,138,138,139,139,139,139,139,140,140,140,141,141,141,141,141,142,142,142,143,143,143,143,143,144,144,144,145,145,145,145,145,146,146,146,147,147,147,147,148,148,148,148,148,149,149,149,150,150,150,150,150,151,151,151,152,152,152,152,153,153,153,153,153,154,154,154,155,155,155,156,156,156,156,156,156,157,157,157,158,158,158,158,158,159,159,159,159,160,160,160,161,161,161,161,162,162,162,162,162,163,163,163,164,164,164,164,165,165,165,165,165,166,166,166,166,167,167,167,168,168,168,168,169,169,169,169,169,170,170,170,170,171,171,171,172,172,172,172,173,173,173,173,173,174,174,174,174,175,175,175,175,176,176,176,177,177,177,177,178,178,178,178,179,179,179,179,179,180,180,180,180,181,181,181,181,182,182,182,183,183,183,183,184,184,184,184,185,185,185,185,186,186,186,186,186,187,187,187,187,188,188,188,188,189,189,189,189,190,190,190,190,191,191,191,191,192,192,192,193,193,193,193,194,194,194,194,195,195,195,195,196,196,196,196,197,197,197,197,198,198,198,198,198,198,199,199,199,199,200,200,200,200,201,201,201,201,202,202,202,202,203,203,203,203,204,204,204,204,205,205,205,205,206,206,206,206,207,207,207,207,208,208,208,208,209,209,209,209,210,210,210,210,211,211,211,211,212,212,212,212,213,213,213,213,214,214,215,215,215,215,216,216,216,216,217,217,217,217,218,218,218,218,218,219,219,219,219,220,220,220,220,221,221,221,221,222,222,222,222,223,223,223,223,223,224,224,224,224,225,225,225,225,226,226,227,227,227,227,228,228,228,228,228,229,229,229,229,230,230,230,230,231,231,231,231,232,232,232,232,232,233,233,233,233,234,234,235,235,235,235,235,236,236,236,236,237,237,237,237,238,238,238,238,238,239,239,239,239,240,240,241,241,241,241,241,242,242,242,242,243,243,243,243,244,244,244,244,244,245,245,245,245,246,246,246,247,247,247,247,248,248,248,248,248,249,249,249,249,250,250,250,250,250,251,251,252,252,252,252,253,253,253,253,253,254,254,254,254,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(53., 0.), brightness_contrast_map(53., 0.),
string_data("0,0,1,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,10,10,10,11,11,11,12,12,12,13,13,14,14,14,15,15,15,16,16,16,17,17,17,18,18,19,19,19,20,20,20,21,21,21,22,22,22,23,23,24,24,24,25,25,25,26,26,26,27,27,27,28,28,29,29,29,30,30,30,31,31,31,32,32,32,33,33,34,34,34,35,35,35,36,36,36,37,37,37,38,38,39,39,39,40,40,40,41,41,41,42,42,42,43,43,44,44,44,45,45,45,46,46,46,47,47,47,48,48,48,49,49,50,50,50,51,51,51,52,52,52,53,53,53,54,54,54,55,55,56,56,56,57,57,57,58,58,58,59,59,59,60,60,60,61,61,62,62,62,63,63,63,64,64,64,65,65,65,66,66,66,67,67,67,68,68,69,69,69,70,70,70,71,71,71,72,72,72,73,73,73,74,74,74,75,75,75,76,76,76,77,77,78,78,78,79,79,79,80,80,80,81,81,81,82,82,82,83,83,83,84,84,84,85,85,85,86,86,86,87,87,87,88,88,88,89,89,89,90,90,90,91,91,91,92,92,92,93,93,93,94,94,94,95,95,95,96,96,96,97,97,97,98,98,98,99,99,99,100,100,100,101,101,101,102,102,102,103,103,103,104,104,104,105,105,105,106,106,106,107,107,107,108,108,108,109,109,109,110,110,110,111,111,111,112,112,112,113,113,113,114,114,114,115,115,115,116,116,116,117,117,117,118,118,118,119,119,119,120,120,120,120,121,121,121,122,122,122,123,123,123,124,124,124,125,125,125,126,126,126,127,127,127,128,128,128,129,129,129,129,130,130,130,131,131,131,132,132,132,133,133,133,134,134,134,135,135,135,135,136,136,136,137,137,137,138,138,138,139,139,139,139,140,140,140,141,141,141,142,142,142,143,143,143,144,144,144,144,145,145,145,146,146,146,147,147,147,147,148,148,148,149,149,149,150,150,150,150,151,151,151,152,152,152,153,153,153,153,154,154,154,155,155,155,156,156,156,156,157,157,157,158,158,158,159,159,159,159,160,160,160,161,161,161,161,162,162,162,163,163,163,163,164,164,164,165,165,165,165,166,166,166,167,167,167,167,168,168,168,169,169,169,169,170,170,170,170,171,171,171,171,172,172,172,173,173,173,173,174,174,174,175,175,175,175,176,176,176,176,177,177,177,178,178,178,178,179,179,179,179,180,180,180,180,181,181,181,182,182,182,182,183,183,183,183,184,184,184,184,185,185,185,186,186,186,186,187,187,187,187,188,188,188,188,189,189,189,189,190,190,190,190,191,191,191,191,192,192,192,192,193,193,193,193,194,194,194,194,195,195,195,195,196,196,196,196,197,197,197,197,198,198,198,198,199,199,199,199,200,200,200,200,200,201,201,201,201,202,202,202,202,203,203,203,203,204,204,204,204,204,205,205,205,205,206,206,206,206,207,207,207,207,207,208,208,208,208,209,209,209,209,209,210,210,210,210,210,211,211,211,211,212,212,212,212,212,213,213,213,213,213,214,214,214,214,215,215,215,215,215,216,216,216,216,216,217,217,217,217,217,218,218,218,218,218,219,219,219,219,219,220,220,220,220,220,221,221,221,221,221,221,222,222,222,222,222,223,223,223,223,223,224,224,224,224,224,224,225,225,225,225,225,226,226,226,226,226,226,227,227,227,227,227,227,228,228,228,228,228,228,229,229,229,229,229,229,230,230,230,230,230,230,231,231,231,231,231,231,232,232,232,232,232,232,232,233,233,233,233,233,233,234,234,234,234,234,234,234,235,235,235,235,235,235,235,236,236,236,236,236,236,236,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255").as_slice() string_data("0,0,1,1,2,2,3,3,4,4,5,5,6,6,6,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,24,24,24,25,25,26,27,27,28,28,29,29,29,30,31,31,32,32,33,33,33,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,43,43,44,44,45,45,46,46,47,48,48,48,49,50,50,50,51,51,52,52,53,53,54,54,55,55,56,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63,63,64,64,65,65,66,66,67,67,67,68,69,69,70,70,71,71,71,72,72,73,73,74,74,74,75,75,76,76,76,77,78,78,79,79,79,80,80,81,81,81,82,82,83,83,84,84,85,85,85,86,86,87,87,88,88,88,89,89,90,90,91,91,91,92,92,93,93,93,94,94,95,95,96,96,96,97,97,98,98,99,99,100,100,100,101,101,101,102,102,103,103,104,104,104,105,105,106,106,106,107,107,107,108,108,108,109,110,110,110,111,111,111,112,112,113,113,113,114,114,115,115,115,116,116,116,117,117,118,118,119,119,119,120,120,120,120,121,121,121,122,122,123,123,123,124,124,125,125,126,126,126,127,127,127,127,128,128,129,129,129,130,130,130,131,131,132,132,132,132,133,133,134,134,134,135,135,135,135,136,136,137,137,137,138,138,138,139,139,139,140,140,141,141,141,141,142,142,143,143,143,143,144,144,145,145,145,145,146,146,147,147,148,148,148,148,148,149,149,149,150,150,150,151,151,151,152,152,153,153,153,153,154,154,154,154,155,155,156,156,156,156,157,157,158,158,158,158,158,159,159,159,160,160,160,161,161,162,162,162,162,162,163,163,163,164,164,164,165,165,165,165,165,166,166,167,167,167,168,168,168,168,169,169,169,169,170,170,170,170,171,171,171,172,172,172,173,173,173,173,173,174,174,174,175,175,175,175,176,176,176,177,177,177,177,178,178,178,179,179,179,179,179,180,180,180,180,180,181,181,182,182,182,182,182,183,183,183,184,184,184,184,185,185,185,185,186,186,186,186,186,186,187,187,187,188,188,188,188,189,189,189,189,189,190,190,190,191,191,191,191,192,192,192,192,192,193,193,193,193,194,194,194,194,194,195,195,195,196,196,196,196,196,197,197,197,197,198,198,198,198,198,198,198,198,199,199,199,199,199,200,200,200,200,201,201,201,201,201,202,202,202,202,202,203,203,203,203,203,204,204,204,204,205,205,205,205,205,206,206,206,206,206,206,206,207,207,207,207,208,208,208,208,208,209,209,209,209,209,210,210,210,210,210,210,210,211,211,211,211,211,212,212,212,212,212,212,212,213,213,213,213,213,214,214,214,215,215,215,215,215,215,215,216,216,216,216,216,216,216,217,217,217,217,217,218,218,218,218,218,218,218,219,219,219,219,219,219,219,220,220,220,220,220,220,220,221,221,221,221,221,221,221,222,222,222,222,222,222,222,223,223,223,223,223,223,223,223,223,224,224,224,224,224,224,224,225,225,225,225,225,225,225,226,226,226,226,226,227,227,227,227,227,227,227,227,228,228,228,228,228,228,228,228,228,229,229,229,229,229,229,229,229,229,230,230,230,230,230,230,230,230,230,231,231,231,231,231,231,231,231,231,231,232,232,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,233,233,234,234,234,234,234,234,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236,236,236,237,237,237,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,239,239,239,239,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(150., 0.), brightness_contrast_map(150., 0.),
string_data("0,1,1,2,3,3,4,5,5,6,7,7,8,9,9,10,11,11,12,13,14,14,15,16,16,17,18,18,19,20,20,21,22,22,23,24,24,25,26,26,27,28,29,29,30,31,31,32,33,33,34,35,35,36,37,37,38,39,39,40,41,41,42,43,43,44,45,45,46,47,47,48,49,49,50,51,51,52,53,53,54,55,55,56,57,57,58,59,59,60,61,61,62,63,63,64,65,65,66,67,67,68,69,69,70,71,71,72,73,73,74,75,75,76,76,77,78,78,79,80,80,81,82,82,83,84,84,85,85,86,87,87,88,88,89,90,90,91,92,92,93,94,94,95,95,96,97,97,98,99,99,100,100,101,102,102,103,104,104,105,105,106,107,107,108,108,109,110,110,111,112,112,113,113,114,115,115,116,116,117,118,118,119,119,120,121,121,122,122,123,123,124,125,125,126,126,127,128,128,129,129,130,130,131,132,132,133,133,134,134,135,136,136,137,137,138,138,139,140,140,141,141,142,142,143,143,144,145,145,146,146,147,147,148,148,149,149,150,151,151,152,152,153,153,154,154,155,155,156,156,157,157,158,158,159,159,160,160,161,161,162,162,163,164,164,165,165,166,166,166,167,167,168,168,169,169,170,170,171,171,172,172,173,173,173,174,174,175,175,176,176,177,177,178,178,179,179,180,180,180,181,181,182,182,183,183,184,184,184,185,185,186,186,187,187,187,188,188,189,189,190,190,190,191,191,192,192,192,193,193,194,194,194,195,195,196,196,196,197,197,197,198,198,199,199,199,200,200,200,201,201,202,202,202,203,203,203,204,204,204,205,205,205,206,206,206,207,207,207,208,208,208,209,209,209,210,210,210,211,211,211,212,212,212,212,213,213,213,214,214,214,215,215,215,215,216,216,216,217,217,217,217,218,218,218,218,219,219,219,219,220,220,220,220,221,221,221,221,222,222,222,222,223,223,223,223,224,224,224,224,225,225,225,225,225,226,226,226,226,226,227,227,227,227,228,228,228,228,228,229,229,229,229,229,229,230,230,230,230,230,231,231,231,231,231,231,232,232,232,232,232,233,233,233,233,233,233,234,234,234,234,234,234,234,235,235,235,235,235,235,235,236,236,236,236,236,236,236,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice() string_data("0,1,2,3,4,6,8,9,11,13,15,16,18,20,22,24,26,28,29,32,33,35,37,39,41,43,44,46,48,50,52,54,56,57,59,61,62,64,66,67,69,71,73,75,76,78,80,81,82,85,86,88,89,91,92,94,95,97,98,100,102,103,104,106,107,109,110,111,113,115,116,117,119,120,121,122,124,125,126,127,129,130,131,133,134,135,136,137,138,139,141,142,143,144,145,146,147,148,149,150,151,153,153,154,156,156,157,158,159,160,161,162,163,164,165,165,166,167,168,169,170,170,171,172,173,173,174,175,176,177,178,178,179,179,180,181,181,182,183,184,184,185,186,186,187,187,188,189,189,190,191,191,191,192,193,193,194,195,195,196,196,197,197,198,198,198,199,199,200,200,201,201,202,202,203,203,203,204,204,205,205,206,206,207,207,207,208,208,209,209,209,209,210,210,211,211,211,212,212,212,212,213,213,214,214,215,215,215,215,216,216,217,217,217,217,218,218,218,218,219,219,219,220,220,220,220,220,221,221,221,221,222,222,222,222,222,223,223,223,223,224,224,224,224,224,225,225,225,225,225,226,226,226,227,227,227,227,227,228,228,228,228,228,228,229,229,229,229,229,229,229,230,230,230,230,230,230,230,231,231,231,231,231,231,231,231,232,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,233,234,234,234,234,234,235,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236,236,236,237,237,237,237,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(-150., -100.), brightness_contrast_map(-150., -100.),
string_data("0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,26,26,26,26,26,27,27,27,27,27,27,27,27,28,28,28,28,28,29,29,29,29,29,29,29,29,29,30,30,30,30,30,31,31,31,31,31,31,31,31,32,32,32,32,32,33,33,33,33,33,33,34,34,34,34,34,34,34,34,35,35,35,35,35,36,36,36,36,36,36,36,36,37,37,37,37,37,38,38,38,38,38,38,38,38,39,39,39,39,39,40,40,40,40,40,40,40,40,41,41,41,41,41,41,42,42,42,42,42,42,42,43,43,43,43,43,43,44,44,44,44,44,44,44,44,45,45,45,45,45,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,48,48,48,48,48,48,49,49,49,49,49,49,49,50,50,50,50,50,50,51,51,51,51,51,51,51,52,52,52,52,52,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,55,55,55,55,55,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,58,58,58,58,58,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,62,62,62,62,62,63,63,63,63,63,63,63,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,67,67,67,67,67,67,67,68,68,68,68,68,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,71,71,71,71,71,71,71,72,72,72,72,72,72,72,73,73,73,73,73,73,73,74,74,74,74,74,74,74,75,75,75,75,75,75,75,76,76,76,76,76,76,76,76,77,77,77,77,77,77,78,78,78,78,78,78,78,78,78,78,79,79,79,79,79,79,79,80,80,80,80,80,80,81,81,81,81,81,81,81,82,82,82,82,82,82,82,82,82,83,83,83,83,83,83,83,84,84,84,84,84,84,84,85,85,85,85,85,85,85,85,85,86,86,86,86,86,86,87,87,87,87,87,87,87,87,87,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,90,90,90,90,90,90,90,90,91,91,91,91,91,91,91,92,92,92,92,92,92,92,92,93,93,93,93,93,93,93,93,94,94,94,94,94,94,94,94,94,95,95,95,95,95,95,95,95,96,96,96,96,96,96,96,96,96,96,97,97,97,97,97,97,97,97,98,98,98,98,98,98,98,99,99,99,99,99,99,99,99,99,99,100,100,100,100,100,100,100,100,101,101,101,101,101,101,101,101,101,102,102,102,102,102,102,102,102,102,103,103,103,103,103,103,103,103,103,104,104,104,104,104,104,104,104,104,105,105,105,105,105,105,105,105,105,105,105,106,106,106,106,106,106,106,106,107,107,107,107,107,107,107,107,107,107,108,108,108,108,108,108,108,108,108,108,109,109,109,109,109,109,109,109,109,110,110,110,110,110,110,110,110,110,110,110,111,111,111,111,111,111,111,111,111,112,112,112,112,112,112,112,112,112,112,113,113,113,113,113,113,113,113,113,113,114,114,114,114,114,114,114,114,114,114,114,115,115,115,115,115,115,115,115,115,115,116,116,116,116,116,116,116,116,116,116,117,117,117,117,117,117,117,117,117,117,118,118,118,118,118,118,118,118,118,118,119,119,119,119,119,119,119,119,119,119,119,120,120,120,120,120,120,120,120,120,121,121,121,121,121,121,121,121,121,121,122,122,122,122,122,122,122,122,122,122,123,123,123,123,123,123,123,123,123,124,124,124,124,124,124,124,124,124,125,125,125,125,125,125,125,125,125,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,128,128,128,128,128,128,129,129,129,129,129,129,130,130,130,130,130,131,131,131,131,132,132,132,132,133,133,134,134,134,135,135,135,136,136,137,138,138,139,140,140,141,142,143,144,145,146,147,149,150,152,154,155,158,160,163,166,169,173,178,183,189,196,204,214,226,240").as_slice() string_data("0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,61,61,61,61,61,61,61,62,62,62,62,63,63,63,63,64,64,64,64,64,65,65,66,66,66,66,67,67,68,68,68,69,69,70,70,71,71,72,72,73,73,73,75,75,76,76,78,78,80,80,80,82,82,84,84,87,87,90,90,90,93,93,97,97,101,101,107,107,107,113,113,121,121,130,130,141,141,141,154,154,172,172,194,194,222,222").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(-77., -100.), brightness_contrast_map(-77., -100.),
string_data("0,0,0,0,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,5,5,5,5,6,6,6,6,6,7,7,7,8,8,8,8,8,9,9,9,9,10,10,10,11,11,11,11,11,12,12,12,12,13,13,13,14,14,14,14,14,15,15,15,16,16,16,16,17,17,17,17,17,18,18,18,19,19,19,19,19,20,20,20,20,21,21,21,22,22,22,22,22,23,23,23,23,24,24,24,24,24,25,25,25,26,26,26,27,27,27,27,27,27,28,28,28,29,29,29,29,29,30,30,30,31,31,31,31,31,32,32,32,32,33,33,33,34,34,34,34,34,35,35,35,35,36,36,36,36,36,37,37,37,38,38,38,38,38,39,39,39,40,40,40,40,40,41,41,41,41,42,42,42,42,42,43,43,43,44,44,44,44,44,45,45,45,45,46,46,46,46,46,47,47,47,47,47,48,48,48,49,49,49,49,49,50,50,50,51,51,51,51,51,52,52,52,52,53,53,53,53,53,54,54,54,54,55,55,55,55,56,56,56,56,56,57,57,57,57,57,58,58,58,59,59,59,59,59,60,60,60,60,60,61,61,61,61,61,62,62,62,63,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66,67,67,67,67,67,68,68,68,69,69,69,69,69,70,70,70,70,70,71,71,71,71,71,72,72,72,72,73,73,73,73,73,74,74,74,74,74,75,75,75,75,75,76,76,76,76,76,77,77,77,77,77,78,78,78,78,78,78,79,79,79,79,79,80,80,80,80,80,81,81,81,81,82,82,82,82,82,82,82,83,83,83,83,84,84,84,84,84,85,85,85,85,85,85,86,86,86,86,86,87,87,87,87,87,87,88,88,88,88,88,89,89,89,89,89,89,90,90,90,90,90,90,90,91,91,91,91,92,92,92,92,92,92,93,93,93,93,93,93,93,94,94,94,94,94,94,95,95,95,95,95,95,96,96,96,96,96,96,96,96,97,97,97,97,97,97,98,98,98,98,98,98,99,99,99,99,99,99,99,100,100,100,100,100,100,101,101,101,101,101,101,101,101,102,102,102,102,102,102,102,103,103,103,103,103,103,103,103,104,104,104,104,104,104,104,105,105,105,105,105,105,105,105,105,106,106,106,106,106,106,106,107,107,107,107,107,107,107,107,107,108,108,108,108,108,108,108,108,109,109,109,109,109,109,109,109,109,110,110,110,110,110,110,110,110,110,110,111,111,111,111,111,111,111,111,112,112,112,112,112,112,112,112,112,112,113,113,113,113,113,113,113,113,113,113,114,114,114,114,114,114,114,114,114,114,114,115,115,115,115,115,115,115,115,115,115,115,116,116,116,116,116,116,116,116,116,116,117,117,117,117,117,117,117,117,117,117,117,117,118,118,118,118,118,118,118,118,118,118,118,118,119,119,119,119,119,119,119,119,119,119,119,119,119,120,120,120,120,120,120,120,120,120,120,120,120,120,121,121,121,121,121,121,121,121,121,121,121,121,121,122,122,122,122,122,122,122,122,122,122,122,122,122,122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,130,130,130,130,130,130,130,130,130,130,130,130,130,131,131,131,131,131,131,131,131,131,131,131,131,132,132,132,132,132,132,132,132,132,132,132,132,133,133,133,133,133,133,133,133,133,134,134,134,134,134,134,134,134,134,134,135,135,135,135,135,135,135,135,135,135,136,136,136,136,136,136,136,136,137,137,137,137,137,137,137,138,138,138,138,138,138,138,139,139,139,139,139,139,139,140,140,140,140,140,140,141,141,141,141,141,141,142,142,142,142,142,143,143,143,143,143,144,144,144,144,144,145,145,145,145,145,146,146,146,147,147,147,147,148,148,148,148,149,149,149,150,150,150,150,151,151,151,152,152,153,153,153,154,154,154,155,155,155,156,156,157,157,158,158,159,159,159,160,160,161,161,162,162,163,164,164,165,166,166,167,168,168,169,169,170,171,172,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,191,192,193,195,196,198,199,201,203,204,206,208,210,212,214,216,218,220,223,225,227,230,232,235,238,240,243,246,249,252").as_slice() string_data("0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,8,8,9,9,9,9,10,10,10,10,10,11,11,11,11,12,12,12,12,12,13,13,13,13,13,14,14,14,14,15,15,15,15,15,16,16,16,16,16,16,17,17,17,17,17,18,18,18,18,18,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21,22,22,22,22,22,22,23,23,23,23,23,24,24,24,24,24,24,24,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,34,34,34,34,34,34,34,34,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,36,37,37,37,37,37,37,37,37,37,38,38,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,40,40,40,40,40,40,40,40,40,40,40,40,40,41,41,41,41,41,41,41,41,41,41,41,41,42,42,42,42,42,42,42,42,42,42,42,42,42,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,74,74,74,74,74,74,75,75,75,75,75,75,75,75,76,76,76,76,76,76,77,77,77,77,77,77,78,78,78,78,78,78,79,79,79,79,79,79,80,80,80,80,81,81,81,81,81,81,82,82,82,82,83,83,83,83,84,84,84,84,85,85,85,85,86,86,86,86,87,87,87,87,88,88,88,88,88,89,89,90,90,90,90,91,91,91,91,92,92,93,93,94,94,94,94,95,95,96,96,96,97,97,97,97,98,98,99,99,100,100,101,101,102,102,103,103,104,104,104,105,105,106,106,107,107,108,108,109,109,110,110,112,112,112,113,113,114,114,116,116,117,117,119,119,120,120,120,122,122,124,124,125,125,127,127,129,129,131,131,131,133,133,135,135,137,137,139,139,141,141,141,144,144,146,146,149,149,152,152,154,154,154,158,158,161,161,164,164,167,167,167,171,171,175,175,179,179,183,183,183,187,187,191,191,196,196,201,201,201,206,206,212,212,217,217,222,222,222,229,229,234,234,241,241,247,247").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(0., -100.), brightness_contrast_map(0., -100.),
string_data("0,0,1,1,2,2,3,3,3,4,4,5,5,6,6,6,7,7,8,8,8,9,9,10,10,11,11,11,12,12,13,13,14,14,14,15,15,16,16,17,17,17,18,18,19,19,19,20,20,21,21,22,22,22,23,23,24,24,24,25,25,26,26,27,27,27,28,28,29,29,29,30,30,31,31,31,32,32,33,33,34,34,34,35,35,36,36,36,37,37,38,38,38,39,39,40,40,40,41,41,42,42,42,43,43,44,44,44,45,45,46,46,46,47,47,47,48,48,49,49,49,50,50,51,51,51,52,52,53,53,53,54,54,54,55,55,56,56,56,57,57,57,58,58,59,59,59,60,60,60,61,61,61,62,62,63,63,63,64,64,64,65,65,65,66,66,66,67,67,67,68,68,69,69,69,70,70,70,71,71,71,72,72,72,73,73,73,74,74,74,75,75,75,76,76,76,77,77,77,78,78,78,78,79,79,79,80,80,80,81,81,81,82,82,82,82,83,83,83,84,84,84,85,85,85,85,86,86,86,87,87,87,87,88,88,88,89,89,89,89,90,90,90,90,91,91,91,92,92,92,92,93,93,93,93,94,94,94,94,95,95,95,95,96,96,96,96,96,97,97,97,97,98,98,98,98,99,99,99,99,99,100,100,100,100,101,101,101,101,101,102,102,102,102,102,103,103,103,103,103,104,104,104,104,104,105,105,105,105,105,105,106,106,106,106,106,107,107,107,107,107,107,108,108,108,108,108,108,109,109,109,109,109,109,110,110,110,110,110,110,110,111,111,111,111,111,111,112,112,112,112,112,112,112,113,113,113,113,113,113,113,114,114,114,114,114,114,114,114,115,115,115,115,115,115,115,115,116,116,116,116,116,116,116,116,117,117,117,117,117,117,117,117,117,118,118,118,118,118,118,118,118,118,119,119,119,119,119,119,119,119,119,119,120,120,120,120,120,120,120,120,120,120,121,121,121,121,121,121,121,121,121,121,121,122,122,122,122,122,122,122,122,122,122,122,123,123,123,123,123,123,123,123,123,123,123,123,124,124,124,124,124,124,124,124,124,124,124,124,124,125,125,125,125,125,125,125,125,125,125,125,125,125,126,126,126,126,126,126,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,130,130,130,130,130,130,130,130,130,130,130,130,130,131,131,131,131,131,131,131,131,131,131,131,131,131,132,132,132,132,132,132,132,132,132,132,132,132,133,133,133,133,133,133,133,133,133,133,133,134,134,134,134,134,134,134,134,134,134,134,135,135,135,135,135,135,135,135,135,135,135,136,136,136,136,136,136,136,136,136,136,137,137,137,137,137,137,137,137,137,138,138,138,138,138,138,138,138,138,139,139,139,139,139,139,139,139,139,140,140,140,140,140,140,140,140,141,141,141,141,141,141,141,141,142,142,142,142,142,142,142,143,143,143,143,143,143,143,144,144,144,144,144,144,144,145,145,145,145,145,145,145,146,146,146,146,146,146,147,147,147,147,147,147,148,148,148,148,148,148,149,149,149,149,149,150,150,150,150,150,150,151,151,151,151,151,152,152,152,152,152,153,153,153,153,153,154,154,154,154,154,155,155,155,155,155,156,156,156,156,157,157,157,157,157,158,158,158,158,159,159,159,159,159,160,160,160,160,161,161,161,161,162,162,162,162,163,163,163,163,164,164,164,165,165,165,165,166,166,166,166,167,167,167,168,168,168,168,169,169,169,169,170,170,170,171,171,171,172,172,172,172,173,173,173,174,174,174,175,175,175,175,176,176,176,177,177,177,178,178,178,179,179,179,180,180,180,181,181,181,182,182,182,183,183,183,184,184,184,185,185,185,186,186,186,187,187,187,188,188,188,189,189,189,190,190,191,191,191,192,192,192,193,193,193,194,194,195,195,195,196,196,196,197,197,197,198,198,199,199,199,200,200,200,201,201,202,202,202,203,203,204,204,204,205,205,205,206,206,207,207,207,208,208,209,209,209,210,210,211,211,211,212,212,212,213,213,214,214,214,215,215,216,216,217,217,217,218,218,219,219,219,220,220,221,221,221,222,222,223,223,223,224,224,225,225,225,226,226,227,227,228,228,228,229,229,230,230,230,231,231,232,232,233,233,233,234,234,235,235,235,236,236,237,237,238,238,238,239,239,240,240,241,241,241,242,242,243,243,244,244,244,245,245,246,246,246,247,247,248,248,249,249,249,250,250,251,251,252,252,252,253,253,254,254,255,255").as_slice() string_data("0,0,1,1,2,3,3,4,5,5,6,7,7,8,8,9,10,10,11,12,12,13,13,14,15,15,16,16,17,17,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,25,26,26,27,27,28,28,28,29,29,30,30,30,31,31,31,32,32,32,33,33,33,34,34,34,35,35,35,35,36,36,36,36,37,37,37,38,38,38,38,39,39,39,39,39,40,40,40,40,40,41,41,41,41,42,42,42,42,42,42,43,43,43,43,43,43,44,44,44,44,44,44,45,45,45,45,45,45,45,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,50,50,50,50,51,51,51,51,51,51,51,51,51,51,51,52,52,52,52,52,52,52,52,52,52,52,52,53,53,53,53,53,53,53,53,53,53,53,53,53,54,54,54,54,54,54,54,54,54,54,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,56,56,56,56,56,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,60,60,60,60,60,61,61,61,61,61,61,61,61,61,61,61,61,62,62,62,62,62,62,62,62,62,62,62,63,63,63,63,63,63,63,63,63,63,63,63,64,64,64,64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,65,65,66,66,66,66,66,66,66,66,66,66,67,67,67,67,67,67,67,67,67,67,68,68,68,68,68,68,68,68,68,69,69,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,75,75,75,75,75,75,75,75,76,76,76,76,76,76,76,77,77,77,77,77,77,77,78,78,78,78,78,78,78,79,79,79,79,79,79,80,80,80,80,80,80,80,81,81,81,81,81,81,82,82,82,82,82,82,83,83,83,83,83,83,84,84,84,84,84,84,85,85,85,85,85,85,86,86,86,86,86,86,87,87,87,87,88,88,88,88,88,88,88,89,89,89,89,90,90,90,90,90,91,91,91,91,91,91,92,92,92,92,92,93,93,93,93,94,94,94,94,94,95,95,95,95,95,96,96,96,96,96,97,97,97,97,97,98,98,98,98,99,99,99,99,100,100,100,100,101,101,101,101,101,102,102,102,102,103,103,103,103,103,104,104,104,105,105,105,105,105,106,106,106,107,107,107,107,107,108,108,108,108,109,109,109,110,110,110,110,110,111,111,111,112,112,112,112,113,113,113,114,114,114,114,114,115,115,115,115,116,116,116,117,117,117,117,118,118,118,119,119,119,119,120,120,120,121,121,121,121,122,122,122,123,123,123,123,124,124,124,125,125,125,125,126,126,126,126,127,127,127,128,128,128,128,129,129,129,130,130,131,131,131,131,132,132,132,133,133,133,133,134,134,134,134,135,135,136,136,136,137,137,137,137,138,138,138,138,139,140,140,140,140,141,141,141,141,142,142,143,143,143,144,144,144,144,145,145,146,146,146,146,147,147,147,147,148,148,149,149,149,150,150,151,151,151,151,152,152,152,152,153,153,154,154,154,154,155,155,156,156,156,157,157,158,158,158,158,159,159,160,160,160,160,161,161,162,162,162,162,163,163,164,164,165,165,165,165,166,166,167,167,167,167,168,168,169,169,169,169,170,170,171,171,172,172,172,172,173,173,174,174,175,175,175,175,176,176,177,177,178,178,178,178,179,179,180,180,181,181,181,181,182,182,183,183,184,184,184,184,185,185,186,186,187,187,187,187,188,188,189,189,190,190,191,191,191,191,192,192,193,193,194,194,194,195,195,195,195,196,196,197,197,198,198,199,199,199,199,200,200,201,201,202,202,203,203,203,204,204,204,204,205,205,206,206,207,207,208,208,209,209,209,209,210,210,210,211,211,212,212,213,213,214,214,215,215,215,215,216,216,216,217,217,218,218,219,219,220,220,221,221,222,222,222,222,222,223,223,224,224,225,225,226,226,227,227,227,228,228,229,229,230,230,231,231,231,231,231,232,232,233,233,234,234,235,235,236,236,236,237,237,238,238,239,239,240,240,240,241,241,242,242,243,243,244,244,244,244,244,245,245,246,246,247,247,247,248,248,249,249,250,250,251,251,251,252,252,253,253,254,254,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(53., -100.), brightness_contrast_map(53., -100.),
string_data("0,0,1,2,3,3,4,4,5,6,6,7,7,8,8,9,10,10,11,11,12,13,14,14,14,15,16,17,17,18,18,19,19,20,21,21,22,22,23,24,24,25,25,26,27,27,28,28,29,29,30,31,31,32,33,33,34,34,35,36,36,37,37,38,38,39,40,40,41,41,42,42,43,44,44,45,45,46,46,47,47,48,49,49,49,50,51,51,52,53,53,53,54,54,55,56,56,57,57,58,58,59,59,60,60,61,61,62,63,63,64,64,64,65,65,66,66,67,67,68,69,69,70,70,70,71,71,72,72,73,73,74,74,75,75,76,76,77,77,78,78,78,79,79,80,80,81,81,81,82,82,83,83,83,84,84,85,85,85,86,86,87,87,88,88,88,89,89,90,90,90,91,91,92,92,92,93,93,93,94,94,94,95,95,95,96,96,96,97,97,97,98,98,98,99,99,99,99,100,100,100,101,101,101,102,102,102,102,103,103,103,103,104,104,104,105,105,105,105,106,106,106,106,107,107,107,107,108,108,108,108,108,109,109,109,109,110,110,110,110,110,111,111,111,111,111,112,112,112,112,112,113,113,113,113,113,114,114,114,114,114,114,115,115,115,115,115,115,116,116,116,116,116,116,117,117,117,117,117,117,118,118,118,118,118,118,118,119,119,119,119,119,119,119,119,120,120,120,120,120,120,120,121,121,121,121,121,121,121,121,122,122,122,122,122,122,122,122,122,123,123,123,123,123,123,123,123,123,124,124,124,124,124,124,124,124,124,124,125,125,125,125,125,125,125,125,125,125,126,126,126,126,126,126,126,126,126,126,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,129,129,129,129,129,130,130,130,130,130,130,130,130,130,130,131,131,131,131,131,131,131,131,131,131,131,132,132,132,132,132,132,132,132,132,132,133,133,133,133,133,133,133,133,133,134,134,134,134,134,134,134,134,134,135,135,135,135,135,135,135,135,135,136,136,136,136,136,136,136,136,137,137,137,137,137,137,137,137,138,138,138,138,138,138,138,139,139,139,139,139,139,139,139,140,140,140,140,140,140,140,141,141,141,141,141,141,141,142,142,142,142,142,142,143,143,143,143,143,143,144,144,144,144,144,144,145,145,145,145,145,145,145,146,146,146,146,146,147,147,147,147,147,148,148,148,148,148,148,149,149,149,149,150,150,150,150,150,150,151,151,151,151,151,152,152,152,152,153,153,153,153,153,154,154,154,154,154,155,155,155,155,156,156,156,156,157,157,157,157,157,158,158,158,158,159,159,159,159,159,160,160,160,160,161,161,161,161,162,162,162,162,163,163,163,163,164,164,164,165,165,165,165,166,166,166,166,167,167,167,168,168,168,168,169,169,169,169,170,170,170,171,171,171,171,172,172,172,172,173,173,173,174,174,174,175,175,175,175,176,176,176,176,177,177,177,178,178,178,179,179,179,179,180,180,180,181,181,181,182,182,182,182,183,183,183,184,184,184,184,185,185,185,186,186,186,186,187,187,187,188,188,188,188,189,189,189,190,190,190,191,191,191,192,192,192,192,193,193,193,193,194,194,195,195,195,195,196,196,196,196,197,197,197,197,198,198,199,199,199,199,200,200,200,200,201,201,201,202,202,202,202,203,203,203,204,204,204,204,205,205,205,205,206,206,206,207,207,207,207,208,208,208,209,209,209,209,210,210,210,211,211,211,211,211,212,212,212,212,213,213,213,214,214,214,214,214,215,215,215,216,216,216,217,217,217,217,217,218,218,218,219,219,219,219,219,220,220,220,220,221,221,221,221,221,222,222,222,222,223,223,223,223,223,224,224,224,224,225,225,225,225,225,226,226,226,226,227,227,227,227,228,228,228,228,228,228,229,229,229,229,230,230,230,230,230,230,230,231,231,231,231,232,232,232,232,233,233,233,233,233,233,233,234,234,234,234,234,235,235,235,235,235,235,235,236,236,236,236,236,237,237,237,237,237,238,238,238,238,238,238,238,238,239,239,239,239,239,240,240,240,240,240,240,241,241,241,241,241,241,241,241,242,242,242,242,242,242,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,255,255,255,255,255,255").as_slice() string_data("0,1,1,2,3,5,6,7,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,30,31,32,33,33,34,34,35,36,36,37,37,38,38,39,39,40,40,41,41,41,42,42,43,43,43,44,44,44,44,45,45,45,46,46,46,47,47,47,47,48,48,48,48,48,49,49,49,49,50,50,50,50,50,51,51,51,51,51,51,52,52,52,52,52,52,53,53,53,53,53,53,53,54,54,54,54,54,54,55,55,55,55,55,55,55,55,56,56,56,56,56,56,56,57,57,57,57,57,57,57,58,58,58,58,58,58,58,58,59,59,59,59,59,59,59,60,60,60,60,60,60,60,60,61,61,61,61,61,61,62,62,62,62,62,62,62,63,63,63,63,63,63,63,64,64,64,64,64,64,65,65,65,65,65,65,66,66,66,66,66,66,67,67,67,67,67,67,68,68,68,68,68,69,69,69,69,69,69,70,70,70,70,70,71,71,71,71,71,71,72,72,72,72,73,73,73,73,73,74,74,74,74,74,75,75,75,75,76,76,76,76,76,77,77,77,77,78,78,78,78,78,79,79,79,79,80,80,80,80,81,81,81,81,82,82,82,82,82,83,83,83,83,84,84,84,85,85,85,85,86,86,86,86,87,87,87,87,88,88,88,88,89,89,89,90,90,90,90,91,91,91,91,92,92,92,93,93,93,93,94,94,94,95,95,95,95,96,96,96,97,97,97,97,98,98,98,99,99,100,100,100,100,101,101,101,102,102,102,103,103,103,104,104,104,104,105,105,105,105,106,106,107,107,107,107,108,108,109,109,109,110,110,110,110,110,111,111,112,112,112,113,113,114,114,114,114,115,115,115,115,116,116,117,117,117,118,118,119,119,119,119,120,120,120,121,121,121,122,122,122,123,123,123,124,124,124,125,125,125,125,126,126,127,127,127,128,128,128,128,129,129,129,130,131,131,131,131,132,132,132,133,133,133,134,134,134,134,135,136,136,136,136,137,137,137,138,138,138,138,139,139,140,140,140,141,141,141,141,142,143,143,143,143,143,144,144,144,145,145,146,146,146,147,147,147,147,147,148,149,149,149,149,150,150,151,151,151,151,152,152,152,152,152,153,154,154,154,154,154,155,156,156,156,156,156,157,158,158,158,158,158,159,159,159,160,160,160,161,161,161,162,162,162,162,162,163,164,164,164,165,165,165,165,165,166,167,167,167,167,167,168,168,168,169,169,169,169,169,170,170,171,171,171,172,172,172,172,172,173,173,173,174,175,175,175,175,175,176,176,176,177,177,177,177,178,178,178,178,179,179,180,180,180,181,181,181,181,181,182,182,182,182,183,183,183,184,184,184,184,184,185,185,185,186,186,186,186,187,187,187,187,187,188,188,188,189,189,189,190,190,190,190,191,191,191,191,191,191,191,192,193,193,193,193,194,194,194,195,195,195,195,195,195,195,196,196,196,196,197,197,197,198,198,198,198,199,199,199,199,199,199,199,200,200,200,201,201,201,201,202,202,202,203,203,203,203,203,203,204,204,204,204,204,204,204,205,205,205,206,206,206,206,207,207,207,207,207,208,208,208,208,209,209,209,209,209,209,209,209,209,210,210,210,210,211,211,211,211,212,212,212,212,212,213,213,213,213,214,214,214,214,214,215,215,215,215,215,215,215,215,215,215,216,216,216,216,217,217,217,217,217,218,218,218,218,219,219,219,219,219,219,220,220,220,220,220,220,221,221,221,222,222,222,222,222,222,222,222,222,222,222,222,223,223,223,223,223,223,224,224,224,224,225,225,225,225,225,225,226,226,226,226,226,226,227,227,227,227,227,227,228,228,228,228,228,228,229,229,229,229,229,229,230,230,230,230,230,230,231,231,231,231,231,231,231,231,231,231,231,231,232,232,232,232,232,232,233,233,233,233,233,233,233,233,234,234,234,234,234,234,235,235,235,235,235,235,236,236,236,236,236,236,237,237,237,237,237,237,237,237,237,238,238,238,238,238,238,239,239,239,239,239,239,240,240,240,240,240,240,240,240,240,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,255,255,255,255").as_slice()
); );
assert_eq!( assert_eq!(
brightness_contrast_map(150., -100.), brightness_contrast_map(150., -100.),
string_data("0,1,2,3,5,6,7,8,9,11,11,13,14,15,16,17,19,19,21,22,23,24,25,27,28,29,30,31,32,33,34,36,36,38,39,40,41,42,43,44,45,46,47,48,49,51,51,53,54,55,56,57,58,59,60,61,61,63,64,65,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,82,83,84,85,85,86,87,88,89,89,90,90,91,92,93,93,94,95,95,96,96,97,98,98,99,99,100,101,101,102,102,103,103,104,104,105,105,106,106,107,107,108,108,108,109,109,110,110,110,111,111,112,112,112,113,113,113,114,114,114,115,115,115,116,116,116,117,117,117,117,118,118,118,119,119,119,119,120,120,120,120,121,121,121,121,121,122,122,122,122,123,123,123,123,123,124,124,124,124,124,124,125,125,125,125,125,126,126,126,126,126,126,127,127,127,127,127,128,128,128,128,128,128,129,129,129,129,129,129,130,130,130,130,130,130,131,131,131,131,131,131,132,132,132,132,132,133,133,133,133,133,134,134,134,134,134,135,135,135,135,135,136,136,136,136,136,137,137,137,137,138,138,138,138,138,139,139,139,139,140,140,140,140,141,141,141,141,142,142,142,142,143,143,143,144,144,144,144,145,145,145,146,146,146,147,147,147,147,148,148,148,149,149,149,150,150,150,151,151,151,152,152,153,153,153,154,154,154,155,155,155,156,156,157,157,157,158,158,159,159,159,160,160,160,161,161,162,162,162,163,163,164,164,165,165,165,166,166,167,167,168,168,168,169,169,170,170,170,171,171,172,172,173,173,174,174,175,175,175,176,176,177,177,177,178,178,179,179,180,180,181,181,181,182,182,183,183,184,184,184,185,185,186,186,186,187,187,188,188,188,189,189,190,190,191,191,191,192,192,193,193,193,194,194,195,195,195,196,196,196,197,197,197,198,198,199,199,199,200,200,200,201,201,202,202,202,203,203,204,204,204,205,205,205,205,206,206,207,207,207,207,208,208,209,209,209,209,210,210,211,211,211,211,212,212,212,212,213,213,213,214,214,214,214,215,215,215,216,216,217,217,217,217,217,218,218,218,219,219,219,219,219,220,220,220,221,221,221,221,221,222,222,222,223,223,223,223,223,223,224,224,224,225,225,225,225,225,225,226,226,226,226,227,227,227,227,228,228,228,228,228,228,228,229,229,229,229,230,230,230,230,230,230,230,230,231,231,231,231,231,232,232,232,232,232,233,233,233,233,233,233,233,233,234,234,234,234,234,234,235,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice() string_data("0,1,3,6,10,14,18,22,25,28,31,33,36,38,39,41,42,44,45,46,47,48,49,50,50,51,51,52,53,53,54,54,55,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63,64,65,65,66,66,67,68,68,69,70,70,71,72,73,74,74,75,76,76,77,78,79,80,81,81,82,83,84,85,86,87,88,89,90,91,92,93,93,94,95,96,97,98,99,100,101,103,103,104,105,107,107,109,110,110,112,113,114,114,116,116,118,119,120,121,122,123,123,125,126,126,128,128,129,131,132,132,133,134,136,136,137,138,139,140,140,141,142,143,144,145,146,146,147,148,149,150,151,152,152,153,154,155,155,156,157,158,159,160,160,161,162,162,163,164,165,165,166,167,167,168,169,169,170,170,172,172,172,173,174,175,175,176,176,178,178,178,179,179,181,181,181,181,182,183,184,184,184,185,185,186,186,187,187,188,188,189,189,190,190,191,191,192,192,193,193,194,194,195,195,195,196,196,197,197,198,198,198,199,199,199,199,200,200,201,201,201,202,203,203,203,204,204,204,204,204,205,205,206,206,206,207,207,207,208,208,209,209,209,209,209,209,210,210,210,211,211,211,211,212,212,212,213,213,213,213,214,214,214,215,215,215,215,215,215,215,215,216,216,216,216,217,217,217,217,218,218,218,218,218,219,219,219,219,220,220,220,220,220,221,221,221,221,222,222,222,222,222,222,222,222,222,222,222,222,223,223,223,223,223,223,224,224,224,224,224,225,225,225,225,225,225,226,226,226,226,226,226,227,227,227,227,227,227,227,227,228,228,228,228,228,228,228,229,229,229,229,229,229,229,229,230,230,230,230,230,230,230,231,231,231,231,231,231,231,231,231,231,231,231,231,231,231,231,231,232,232,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,233,234,234,234,234,234,234,234,234,234,234,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236,236,237,237,237,237,237,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,240,240,240,240,240,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243,243,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255").as_slice()
); );
} }
} }

View file

@ -301,9 +301,18 @@ impl Color {
} }
} }
pub fn from_luminance(luminance: f32) -> Color {
Color {
red: luminance,
green: luminance,
blue: luminance,
alpha: 1.,
}
}
pub fn with_luminance(&self, luminance: f32) -> Color { pub fn with_luminance(&self, luminance: f32) -> Color {
let d = luminance - self.luminance_rec_601_rounded(); let delta = luminance - self.luminance_rec_601_rounded();
self.map_rgb(|c| (c + d).clamp(0., 1.)) self.map_rgb(|c| (c + delta).clamp(0., 1.))
} }
pub fn saturation(&self) -> f32 { pub fn saturation(&self) -> f32 {

View file

@ -154,13 +154,16 @@ fn translate_node<Data: TransformMut>(offset: DVec2, mut translatable: Data) ->
mod test { mod test {
use super::*; use super::*;
use crate::raster::*; use crate::raster::*;
use glam::DAffine2;
#[allow(unused_imports)]
use graphene_core::ops::{AddNode, CloneNode}; use graphene_core::ops::{AddNode, CloneNode};
use graphene_core::raster::*; use graphene_core::raster::*;
use graphene_core::structural::Then; use graphene_core::structural::Then;
use graphene_core::transform::{Transform, TransformMut}; use graphene_core::transform::{Transform, TransformMut};
use graphene_core::value::{ClonedNode, ValueNode}; use graphene_core::value::{ClonedNode, ValueNode};
use glam::DAffine2;
#[test] #[test]
fn test_translate_node() { fn test_translate_node() {
let image = Image::new(10, 10, Color::TRANSPARENT); let image = Image::new(10, 10, Color::TRANSPARENT);

View file

@ -1,7 +1,7 @@
use dyn_any::{DynAny, StaticType, StaticTypeSized}; use dyn_any::{DynAny, StaticType, StaticTypeSized};
use glam::{BVec2, DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphene_core::raster::{Alpha, Channel, Color, Image, ImageFrame, Luminance, Pixel, RasterMut, Sample}; use graphene_core::raster::{Alpha, Channel, Image, ImageFrame, Luminance, Pixel, RasterMut, Sample};
use graphene_core::transform::Transform; use graphene_core::transform::Transform;
use graphene_core::value::{ClonedNode, ValueNode}; use graphene_core::value::{ClonedNode, ValueNode};
use graphene_core::Node; use graphene_core::Node;
@ -300,7 +300,6 @@ fn blend_image<_P: Clone, MapFn, Frame: Sample<Pixel = _P> + Transform, Backgrou
where where
MapFn: for<'any_input> Node<'any_input, (_P, _P), Output = _P> + 'input, MapFn: for<'any_input> Node<'any_input, (_P, _P), Output = _P> + 'input,
{ {
let foreground_size = foreground.transform().decompose_scale();
let background_size = DVec2::new(background.width() as f64, background.height() as f64); let background_size = DVec2::new(background.width() as f64, background.height() as f64);
// Transforms a point from the background image to the forground image // Transforms a point from the background image to the forground image