Expand description
Comprehensive colorspace conversions in pure Rust
The working data structure is [DType; ValidChannels]
, where DType is one of
f32
or f64
and ValidChannels is either 3 or 4, with the 4th channel representing
alpha and being unprocessed outside of typing conversions
Formulae are generally taken from their research papers or Wikipedia and validated against colour-science https://github.com/colour-science/colour
This crate references CIE Standard Illuminant D65 for functions to/from CIE XYZ
Structs§
- Channels
- 3 channels, or 4 with alpha. Alpha ignored during space conversions.
Enums§
- Space
- Defines colorspace pixels will take.
Constants§
- D65
- Standard Illuminant D65.
- HIGH2023_
MEAN - Mean value of the HK delta for CIE LCH(ab), High et al 2023 implementation.
Traits§
- DType
- Trait for all supported data types in colcon
- FromF32
- Convert an F32 ito any supported DType
- Valid
Channels - 3 channels, or 4 with alpha. Alpha ignored during space conversions.
Functions§
- _ictcp_
to_ lrgb - Convert ICtCp to LRGB. Unvalidated, WIP
- _lrgb_
to_ ictcp - Convert LRGB to ICtCp. Unvalidated, WIP
- cielab_
to_ xyz - Convert from CIE LAB to CIE XYZ.
- convert_
space - Runs conversion functions to convert
pixel
from oneSpace
to another in the least possible moves. - convert_
space_ chunked - Runs conversion functions to convert
pixel
from oneSpace
to another in the least possible moves. - convert_
space_ ffi - Same as
convert_space_sliced
but with FFI types. - convert_
space_ sliced - Runs conversion functions to convert
pixel
from oneSpace
to another in the least possible moves. - hex_
to_ irgb - Create integer RGB set from hex string.
Will default to 255 for alpha if 4 channels requested but hex length is 6.
Use
hex_to_irgb_default
to customize this. - hex_
to_ irgb_ default - Create integer RGB set from hex string.
DEFAULT
is only used when 4 channels are requested but 3 is given. - hk_
high2023 - Returns difference in perceptual lightness based on hue, aka the Helmholtz-Kohlrausch effect. High et al 2023 implementation.
- hk_
high2023_ comp - Compensates CIE LCH’s L value for the Helmholtz-Kohlrausch effect. High et al 2023 implementation.
- hsv_
to_ srgb - Convert from HSV to sRGB.
- irgb_
to_ hex - Create a hexadecimal string from integer RGB.
- irgb_
to_ srgb - Convert integer (0..255) RGB to floating (0.0..1.0) RGB.
- jzazbz_
to_ xyz - Convert JzAzBz to CIE XYZ
- lab_
to_ lch - Converts an LAB based space to a cylindrical representation.
- lch_
to_ lab - Retrieves an LAB based space from its cylindrical representation.
- lrgb_
to_ srgb - Convert from Linear RGB to sRGB by applying the inverse sRGB EOTF
- lrgb_
to_ xyz - Convert from Linear Light RGB to CIE XYZ, D65 standard illuminant
- oklab_
to_ xyz - Convert from OKLAB to CIE XYZ.
- pq_eotf
- Dolby Perceptual Quantizer Electro-Optical Transfer Function primarily used for ICtCP
- pq_oetf
- Dolby Perceptual Quantizer Optical-Electro Transfer Function primarily used for ICtCP
- pqz_
eotf - Dolby Perceptual Quantizer Electro-Optical Transfer Function modified for JzAzBz
- pqz_
oetf - Dolby Perceptual Quantizer Optical-Electro Transfer Function modified for JzAzBz
- srgb_
eotf - sRGB Electro-Optical Transfer Function
- srgb_
oetf - Inverse sRGB Electro-Optical Transfer Function
- srgb_
to_ hsv - Convert from sRGB to HSV.
- srgb_
to_ irgb - Convert floating (0.0..1.0) RGB to integer (0..255) RGB.
- srgb_
to_ lrgb - Convert from sRGB to Linear RGB by applying the sRGB EOTF
- str2col
- Convert a string into a space/array combo. Separated with spaces, ‘;’, ‘:’, or ‘,’
- str2space
- Convert a string into a pixel of the requested Space.
- str2space_
ffi - Same as
str2space
but with FFI types - unweave
- Create an array of separate channel buffers from a single interwoven buffer. Copies the data.
- weave
- Create a monolithic woven buffer using unwoven independent channel buffers. Copies the data.
- xyz_
to_ cielab - Convert from CIE XYZ to CIE LAB.
- xyz_
to_ jzazbz - Convert CIE XYZ to JzAzBz
- xyz_
to_ lrgb - Convert from CIE XYZ to Linear Light RGB.
- xyz_
to_ oklab - Convert from CIE XYZ to OKLAB.