Crate colcon

Source
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
ValidChannels
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 one Space to another in the least possible moves.
convert_space_chunked
Runs conversion functions to convert pixel from one Space 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 one Space 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.