parallelize temporary lab image conversion
This commit is contained in:
parent
73c4d96577
commit
b290ca866e
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1463,6 +1463,7 @@ dependencies = [
|
|||
"mime",
|
||||
"minijinja",
|
||||
"palette",
|
||||
"rayon",
|
||||
"rusqlite",
|
||||
"serde",
|
||||
"strum",
|
||||
|
|
|
@ -16,6 +16,7 @@ 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"] }
|
||||
|
|
|
@ -4,8 +4,9 @@ use serde::{Deserialize, Serialize};
|
|||
use tracing::instrument;
|
||||
|
||||
use image::Rgb as imgRgb;
|
||||
use palette::color_difference::{Ciede2000, HyAb};
|
||||
use palette::color_difference::Ciede2000;
|
||||
use palette::{cast::FromComponents, IntoColor, Lab, Srgb};
|
||||
use rayon::prelude::*;
|
||||
|
||||
#[derive(
|
||||
strum::EnumString, strum::Display, Serialize, Deserialize, PartialEq, Eq, Debug, Clone,
|
||||
|
@ -215,10 +216,7 @@ impl<'a> Ditherer for ErrorDiffusion<'a> {
|
|||
let srgb = <&[Srgb<u8>]>::from_components(&**img);
|
||||
let (xsize, ysize) = img.dimensions();
|
||||
// our destination buffer.
|
||||
let mut temp_img: Vec<Lab> = Vec::with_capacity((xsize * ysize) as usize);
|
||||
for pix in srgb {
|
||||
temp_img.push(pix.into_format().into_color());
|
||||
}
|
||||
let mut temp_img: Vec<Lab> = srgb.par_iter().map(|s| s.into_format().into_color()).collect();
|
||||
let lab_palette: Vec<Lab> = output.palette.iter().map(|c| Lab::from_color(*c)).collect();
|
||||
|
||||
// TODO: rework this to make more sense.
|
||||
|
|
Loading…
Reference in a new issue