1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//!
//! [](https://travis-ci.com/anderslanglands/colorspace-rs)
//!
//! # colorspace
//!
//! A crate for colorimetry in Rust.
//! This crate contains types and functions for working with color. The intended use is to support rendering applications (I use it to manage color in a spectral pathtracer), but if you want to be able to convert between spectral, XYZ, L'a'b' and RGB spaces of various flavors such as sRGB, ACES, DCI P3 and ALEXA Wide Gamut then this is the crate for you.
//!
//! This crate is still WIP but is fairly stable. Some minor refactoring may occur, but the core types are complete and stable. Future development will be mostly about adding functionality and SIMD-ifying as many operations as possible. I also intend to integrate OCIO at some point.
//!
//! ## Types
//! ### Tristimulus
//! The library contains two main types for working with color values. `XYZf` and `RGBf` can be either single- or double-precision and have all the expected mathematical operations defined.
//!
//! The `RGBu8` and `RGBu16` types are for storage only (for writing to images or passing to e.g. OpenGL for display) and do not define any operations. To do maths with them you must convert to `RGBf` first
//!
//! ### Spectral Power Distribution
//! `SPD`s are defined as a pair of `Vec`s of wavelengths and associated values. The library supplies spectral data for CIE illuminants in the `illuminant` module, and for the color checker chart in the `color_checker` module.
//!
//! ## Examples
//! ### Convert a slice of 32-bit sRGB colors to 8-bit DCI-P3
//! ```rust
//! use colorspace::*;
//! # let px_srgb = vec![rgbf32(0.0, 0.0, 0.0); 1];
//! let srgb = &color_space_rgb::model_f32::SRGB;
//! let dci_p3 = &color_space_rgb::model_f32::DCI_P3;
//! let mut px_dci_p3_u8 = vec![rgbu8(0, 0, 0); px_srgb.len()];
//! rgb_to_rgb(srgb, dci_p3, &px_srgb, &mut px_dci_p3_u8);
//! ```
//!
//! ### Spectral to 8-bit, gamma-encoded sRGB conversion
//! ```rust
//! use colorspace::*;
//!
//! // Convert the spectral data for a measured MacBeth chart swatch to XYZ
//! // using the CIE 1931 2-degree CMFs and a D65 illuminant
//! let xyz = colorchecker::SPECTRAL["dark_skin"]
//! .to_xyz(&illuminant::spd::D65, &cmf::CIE_1931_2_DEGREE);
//!
//! // Convert the XYZ value to scene-referred (i.e. linear) sRGB by first creating
//! // the conversion matrix and then applying it
//! let model_srgb = &color_space_rgb::model_f64::SRGB;
//! let xf_xyz_to_srgb = xyz_to_rgb_matrix(model_srgb.white, model_srgb);
//! let rgb = xyz_to_rgb(&xf_xyz_to_srgb, xyz);
//!
//! // Convert the scene-referred sRGB value to an 8-bit, display-referred
//! // value by applying the opto-electrical transfer function and using RGBu8's
//! // From<RGBf32> impl
//! let rgb: RGBu8 = model_srgb.encode(rgb).into();
//!
//! assert_eq!(rgb, rgbu8(115, 82, 68));
//! ``
//!
//! ## Licence
//! Copyright [2018-2020] [Anders Langlands]
//! colorspace is licensed under Apache License, Version 2.0
//! http://www.apache.org/licenses/LICENSE-2.0
//!
//! This crate contains some data taken from the excellent colour-science python
//! library by Mansencal et al.: <https://www.colour-science.org>
//! Copyright (c) 2013-2018, Colour Developers
//!
//! Most of the conversion algorithms are based on those published at
//! Bruce Lindbloom's site: <http://www.brucelindbloom.com>
//! Copyright © 2001 - 2018 Bruce Justin Lindbloom.
//!
//! BabelColor color-checker data is copyright © 2004‐2012 Danny Pascale (www.babelcolor.com); used with permission.
//! <http://www.babelcolor.com/index_htm_files/ColorChecker_RGB_and_spectra.xls>
//! <http://www.babelcolor.com/index_htm_files/ColorChecker_RGB_and_spectra.zip>
//!
//! Contains data from https://github.com/imallett/simple-spectral accompanying the EGSR 2019 paper "Mallett & Yuksel - Spectral Primary Decomposition for Rendering with sRGB Reflectance".
//!
extern crate derive_more;
extern crate maplit;
pub use CMF;
pub use InterpolatorLinear;
pub use InterpolatorSprague;
pub use ;
pub use ;
pub use ;
pub use ;
pub use *;
pub use ;
pub use SPD;
pub use *;
pub use delta_E_2000 as delta_E;
pub use ;
pub use spd_to_lumens;