Expand description
Simple colorspace conversions in pure Rust.
All conversions are in-place, except when converting to/from integer and hexadecimal. Formulas are generally taken from Wikipedia with correctness verified against both https://www.easyrgb.com and BABL.
Helmholtz-Kohlrausch compensation formulae sourced from https://onlinelibrary.wiley.com/doi/10.1002/col.22839
This crate references CIE Standard Illuminant D65 for functions to/from CIE XYZ
Enums
- Defines colorspace pixels will take.
Constants
- Standard Illuminant D65.
- Mean value of the HK delta, High et al 2023 implementation. Measured with 36000 steps in the hk_exmample file @ 100 C(ab) Cannot make a const fn: https://github.com/rust-lang/rust/issues/57241
Functions
- Runs conversion functions to convert
pixelfrom oneSpaceto another in the least possible moves. - Same as
convert_space, ignores the 4th value inpixel. Just a convenience function. - Runs conversion functions to convert
pixelfrom oneSpaceto another in the least possible moves. Caches conversion graph for faster iteration. - Same as
convert_space_slicedbut with FFI types. Returns 0 on success, 1 on invalidfrom, 2 on invalidto, 3 on invalidpixels - Runs conversion functions to convert
pixelfrom oneSpaceto another in the least possible moves. Caches conversion graph for faster iteration. Ignores remainder values in slice. - Gamma corrects a single linear light value
- Expand gamma of a single value to linear light
- Create integer RGB set from hex string. Not RGB specific, but other formats typically aren’t represented as hexadecimal.
- Compensates LCH’s L value for the Helmholtz-Kohlrausch effect. High et al 2023 implementation.
- Returns difference in perceptual lightness based on hue, aka the Helmholtz-Kohlrausch effect. High et al 2023 implementation.
- Convert from HSV to sRGB.
- Create a hexadecimal string from integer RGB. Not RGB specific, but other formats typically aren’t represented as hexadecimal.
- Convert integer (0..255) RGB to floating (0.0..1.0) RGB. Not RGB specific, but other formats typically aren’t represented as integers.
- Convert from CIE LAB to CIE LCH. https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model
- Convert from CIE LAB to CIE XYZ. https://en.wikipedia.org/wiki/CIELAB_color_space#From_CIELAB_to_CIEXYZ
- Convert from CIE LCH to CIE LAB. https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model
- Convert from Linear Light RGB to sRGB. https://en.wikipedia.org/wiki/SRGB#From_CIE_XYZ_to_sRGB
- Convert from Linear Light RGB to CIE XYZ, D65 standard illuminant https://en.wikipedia.org/wiki/SRGB#From_sRGB_to_CIE_XYZ
- Convert from OKLAB to CIE XYZ. https://bottosson.github.io/posts/oklab/
- Convert from sRGB to HSV.
- Convert floating (0.0..1.0) RGB to integer (0..255) RGB. Simply clips values > 1.0 && < 0.0. Not RGB specific, but other formats typically aren’t represented as integers.
- Convert from sRGB to Linear Light RGB. https://en.wikipedia.org/wiki/SRGB#From_sRGB_to_CIE_XYZ
- Convert from CIE XYZ to CIE LAB. https://en.wikipedia.org/wiki/CIELAB_color_space#From_CIEXYZ_to_CIELAB
- Convert from CIE XYZ to Linear Light RGB. https://en.wikipedia.org/wiki/SRGB#From_CIE_XYZ_to_sRGB
- Convert from CIE XYZ to OKLAB. https://bottosson.github.io/posts/oklab/