RGB2SPEC application
rgb2spec is a small utility that converts an RGB color to a spectral distribution (SD).
# Building and Installation
## Building
rgb2spec is built by default when building Malia Rendering Framework.
To build/rebuild only rgb2spec, use the dedicated Cmake target:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bash
cd /your/build/directory/
cmake /path/to/MRF/root/
make rgb2spec
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! WARNING
[Eigen3](https://gitlab.com/libeigen/eigen) is a required to build the rgb2spec tool.
## Installation
As usual, installation is done by a simple:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bash
cd /your/build/directory/
make install
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Input Data
Input can be either :
- a triple (r,g,b) passed on the command line
- an HDR image
- a LDR image
# Output data
When passing a single color on the command line rgb2spec will save a text file that contains the spectral distribution.
When passing an image, the output will be a spectral image (.hdr/.raw format),
Any output of rgb2spec can be visualized in [SpectralViewer](https://adufay.gitlabpages.inria.fr/SpectralViewer/index.html).
# Command line Options
* -h or -help : prints a help message
* -in_color {float,float, float} : Red Green Blue values
* -in_file {string} : filename to a LDR or HDR image
* -out {string} : filename where the spectrum will be saved.
When not set, the default output is out.spd for a color input and out.hdr|raw for an image input.
* -xyz_curves : allows to specify which CIE-XYZ sensitivity curves will be used.
Possible values are :
+ CIE_1931_2DEG : the two degrees CIE standard observer curves from 1931
+ CIE_XYZ_1964_10DEG : the 10 degrees CIE standard observer curves from 1964
by default the curves from 1931 are used.
* -reflectivity : the color is assumed to represent a value
associated with BRDF or reflectivity. Therefore, the spectral curve
values should be in the range of [0,1]
* -nbw {uint value} : number of wavelengths for the spectral image. The range 360 to 830 nm will be discreetized with the given number.
# Caveats
Remember that converting an hdr image to a spectral image can produce huge file. For example a 2K HDR image converted at 1nm resolution will generate a 3.7 GB file!
# Performance
Input Image | Conversion Timing | Wavelength Resolution | Architecture
-------------|--------------------|-------------------------|-----------------------------
[Pool 2K](https://hdrihaven.com/hdri/?h=pool) HDR | 0.584 seconds | 48 values equiv. 10nm | Intel i7-3770K CPU @ 3.50GHz
[Pool 2K](https://hdrihaven.com/hdri/?h=pool) HDR | 7.12 seconds | 471 values equiv. 1nm | Intel i7-3770K CPU @ 3.50GHz
# The Maths behind RGB2SPEC
*********************************************************************************************
* .-------------. .-------------. .-------------.
* | Non-Linear | | Linear | | CIE | .---------------.
* | RGB +--+->| RGB +----+--+->| XYZ +------>+ Spectral |
* | Color Space | | Color Space | | | SPACE | | Distribution |
* '-------------' '-------------' | '-------------' '---------------'
* Color Space
* Illuminant
*
*
*********************************************************************************************