#rgb #convert #spectrum #rendering #graphics

bin+lib rgb2spec

Converts RGB colors to reflectance spectra

2 releases

0.1.1 Dec 10, 2022
0.1.0 Nov 2, 2022

#486 in Science

25 downloads per month

BSD-3-Clause

47KB
1K SLoC

rgb2spec-rs

crates.io

This crate is a port of rgb2spec, an implementation of the paper "A Low-Dimensional Function Space for Efficient Spectral Upsampling" by Wenzel Jakob and Johannes Hanika.

It can be used to convert RGB colors in various color spaces to coefficent representations of reflectance spectra. These spectra can then be evaluated for wavelengths in the visible spectrum.

Usage

See the crate documentation or examples/ for example usages.

CLI

The crate also includes a command line program that can be used to compute a model and save it to a file. Use cargo run in the crate's root to execute it.


lib.rs:

rgb2spec-rs

This crate is a port of rgb2spec, an implementation of this paper by Wenzel Jakob and Johannes Hanika.

It can be used to convert RGB colors in various color spaces to coefficent representations of reflectance spectra. These spectra can then be evaluated for wavelengths in the visible spectrum.

Example

use rgb2spec::{self, RGB2Spec};

let rgb = [1.0, 1.0, 0.3];
let rgb2spec = RGB2Spec::load("examples/out.spec")?;

let coefficients = rgb2spec.fetch(rgb);
let wavelength = 480.0;
let reflectance = rgb2spec::eval_precise(coefficients, wavelength);

No runtime deps