Calculate Delta E (color difference) between two colors in CIE Lab space.
extern crate deltae;
use deltae::{DeltaE, DEMethod::DE2000};
use deltae::color::LabValue;
use std::str::FromStr;
fn main() {
let lab0 = LabValue::from_str("89.73, 1.88, -6.96").unwrap();
let lab1 = LabValue {
l: 95.08,
a: -0.17,
b: -10.81,
};
println!("{}", lab0);
let de0 = DeltaE::new(&lab0, &lab1, DE2000).round_to(4);
println!("{}: {}", de0.method, de0.value);
let de1 = DeltaE::from(
"89.73, 1.88, -6.96",
"95.08, -0.17, -10.81",
"DE2000"
).unwrap();
assert_eq!(de0, de1.round_to(4));
let lch0 = lab0.to_lch();
let lab2 = lch0.to_lab();
println!("{}", lch0);
assert_eq!(lab0.round_to(4), lab2.round_to(4));
}
color | Manipulate and convert CIE L*a*b* and Lch colors.
|