Swap to using palette's FromStr implementation for colors. Now 3 or 6 digit hex colors are permitted.
Use the special-cased Srgb/LinSrgb conversion between u8 and f32/f64 where possible, that version uses a lookup table and approximation
Speedup gains increase as image size increases. On a 4500x3000 image, a 44% speedup was seen reducing the total time to calculate centroids from 7.8s to 4.3s after switching from into_format to using into_linear. The speedup is closer to 15-17% on smaller images (320x200) but still noticeable when measured.
FromStr
implementation for colors. Now 3 or 6 digit hex colors are permitted.Srgb
/LinSrgb
conversion betweenu8
andf32
/f64
where possible, that version uses a lookup table and approximationSpeedup gains increase as image size increases. On a 4500x3000 image, a 44% speedup was seen reducing the total time to calculate centroids from 7.8s to 4.3s after switching from
into_format
to usinginto_linear
. The speedup is closer to 15-17% on smaller images (320x200) but still noticeable when measured.Rgb
, converting them toLab
, and calculating the centroids. Prompted from this discussion https://github.com/Ogeon/palette/discussions/341#discussioncomment-6561118into_format
into_linear