Expand description
Simple colorspace conversions in pure Rust.
All conversions are in-place, except when converting to/from integer and hexadecimal. Formulae are generally taken from their research papers or Wikipedia and validated against colour-science https://github.com/colour-science/colour
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. - Create integer RGB set from hex string. Not RGB specific, but other formats typically aren’t represented as hexadecimal.
- Returns difference in perceptual lightness based on hue, aka the Helmholtz-Kohlrausch effect. High et al 2023 implementation.
- Compensates LCH’s L value for 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 JzAzBz to CIE XYZ https://opg.optica.org/oe/fulltext.cfm?uri=oe-25-13-15131
- Convert CIE XYZ to CAM16-UCS Convert LRGB to ICtCp https://www.itu.int/rec/R-REC-BT.2100/en 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 CAM16-UCS to CIE XYZ Convert ICtCp to LRGB https://www.itu.int/rec/R-REC-BT.2100/en Convert from CIE LCH to CIE LAB. https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model
- Convert from Linear RGB to sRGB by applying the inverse sRGB EOTF https://www.color.org/chardata/rgb/srgb.xalter
- 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/
- sRGB Electro-Optical Transfer Function https://en.wikipedia.org/wiki/SRGB#Computing_the_transfer_function
- Inverse sRGB Electro-Optical Transfer Function https://en.wikipedia.org/wiki/SRGB#Computing_the_transfer_function
- 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 RGB by applying the sRGB EOTF https://www.color.org/chardata/rgb/srgb.xalter
- Convert a string into a space/array combo. Can separate with parentheses, spaces, ‘;’, ‘:’, or ‘,’ Ex: “0.2, 0.5, 0.6”, “lch: 50 20 120” “oklab(0.2 0.6 90)”
- Convert a string into a pixel of the requested Space Shorthand for str2col() -> convert_space()
- Convert CIE XYZ to JzAzBz https://opg.optica.org/oe/fulltext.cfm?uri=oe-25-13-15131
- 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/