From 73c4d96577795fb684616b0fedf863c02e59d212 Mon Sep 17 00:00:00 2001 From: saji Date: Fri, 2 Aug 2024 11:59:08 -0500 Subject: [PATCH] Revert 2 commits 0267c3d 'update regression tests to match hyab' 8816176 'make lab conversion parallel; use hyab' --- Cargo.lock | 1 - Cargo.toml | 1 - src/dither.rs | 11 ++++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac1695c..024a7ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1463,7 +1463,6 @@ dependencies = [ "mime", "minijinja", "palette", - "rayon", "rusqlite", "serde", "strum", diff --git a/Cargo.toml b/Cargo.toml index 153f925..fee9c2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ linux-embedded-hal = { version = "0.4.0"} mime = "0.3.17" minijinja = "2.1.0" palette = "0.7.6" -rayon = "1.10.0" rusqlite = { version = "0.32.1", features = ["bundled"] } serde = { version = "1.0.204", features = ["derive"] } strum = { version = "0.26.3", features = ["derive"] } diff --git a/src/dither.rs b/src/dither.rs index 77ed2be..7ea316a 100644 --- a/src/dither.rs +++ b/src/dither.rs @@ -6,7 +6,6 @@ use tracing::instrument; use image::Rgb as imgRgb; use palette::color_difference::{Ciede2000, HyAb}; use palette::{cast::FromComponents, IntoColor, Lab, Srgb}; -use rayon::prelude::*; #[derive( strum::EnumString, strum::Display, Serialize, Deserialize, PartialEq, Eq, Debug, Clone, @@ -95,7 +94,7 @@ fn nearest_neighbor(input_color: Lab, palette: &[Lab]) -> (u8, Lab) { .map(|(idx, p_color)| { ( idx, - input_color.hybrid_distance(*p_color), // this is CIEDIE2000 based and highly accurate. + input_color.difference(*p_color), // this is CIEDIE2000 based and highly accurate. input_color - *p_color, ) }) @@ -215,9 +214,11 @@ impl<'a> Ditherer for ErrorDiffusion<'a> { // first, a view into the rgb components let srgb = <&[Srgb]>::from_components(&**img); let (xsize, ysize) = img.dimensions(); - // our temporary buffer. we push the error here. - let mut temp_img: Vec = srgb.par_iter().map(|p| p.into_format().into_color()).collect(); - + // our destination buffer. + let mut temp_img: Vec = Vec::with_capacity((xsize * ysize) as usize); + for pix in srgb { + temp_img.push(pix.into_format().into_color()); + } let lab_palette: Vec = output.palette.iter().map(|c| Lab::from_color(*c)).collect(); // TODO: rework this to make more sense.