This repository contains the supporting code to read and write OpenEXR spectral images.
Our article An OpenEXR Layout for Spectral Images published in the Journal of Computer Graphics Techniques provides a description of the layout.
You may also find sample spectral images useful: ZIP Archive.
To load OpenEXR spectral image, you can use Spectral Viewer.
libcontains the main C++ code.appcontains sample C++ applications using the provided C++ library.pythoncontains a Python example to load spectral OpenEXR files using OpenImageIO.
To compile this code, you need a C++11 compliant compiler, the OpenEXR library installed on your system and CMake.
mkdir build
cd build
cmake ..
makeThis will compile an example program.
You can find in app several sample programs using spectral OpenEXR.
Macbeth executable (macbeth) generates a Macbeth colour chart using
the spectral data from:
http://www.babelcolor.com/colorchecker-2.htm. It will generate a file
Macbeth.exr from the execution place.
./bin/macbethFluo EXR executable (fluo-exr) generates a simple checker-board made
of two fluorescent patches: 3M fluorescent yellow Post-It (R) sticker
and 3M fluorescent pink Post-It (R) sticker. Data courtesy of
Labsphere Inc. It will generate a file BiSpectral.exr
./bin/fluo-exrExport spectrum executable (export-spectrum) extracts from the given
pixel location the stored spectrum in an ASCII file. Each columns
correspond to a polarisation component if present in the image. S_0,
S_1, S_2, S_3 for emissive images and T for reflective
images. First column is the wavelength in manometers. Each column is
separated by a space.
It takes as arguments:
- A spectral EXR
- The x coordinate of the pixel to extract
- The y coordinate of the pixel to extract
- The output file
./bin/export-spectrum Macbeth.exr 15 15 Macbeth.txtYou can plot the spectrum using gnuplot
plot "Macbeth.txt" u 1:2 w lineExport reradiation executable (export-reradiation) extracts from the
give pixel location the stored reradiation matrix in a ASCII file.
It takes as arguments:
- A bi-spectral EXR
- The x coordinate of the pixel to extract
- The y coordinate of the pixel to extract
- The output file
./bin/export-spectrum BiSpectral.exr 15 15 reradiation.txtYou can plot the reradiation matrix using gnuplot
plot "reradiation.txt" matrix w imageMerge EXR executable (merge-exr) creates an emissive spectral EXR
from a folder containing collection of monochromatic EXRs. You can use
the Cornell box data as input
http://www.graphics.cornell.edu/online/box/data.html.
It takes as arguments:
- Folder path containing the images
- Starting wavelength (in manometers)
- Increment of wavelength between images (in manometers)
- Output file
- Optional additional arguments:
- Camera response in CSV format (comma separated)
- Lens transmission in CSV format (comma separated)
- Each filter corresponding to each channel transmissions in CSV format (comma separated)
To convert the Matlab matrices of the Cornell data in CSV format, we use the following GNU Octave code:
csvwrite("F1.csv", [wavelen F1])
csvwrite("F2.csv", [wavelen F2])
csvwrite("F3.csv", [wavelen F3])
csvwrite("F4.csv", [wavelen F4])
csvwrite("F5.csv", [wavelen F5])
csvwrite("F6.csv", [wavelen F6])
csvwrite("F7.csv", [wavelen F7])
load lens.mat
csvwrite("lens.csv", [wavelen lens])
load camera.mat
csvwrite("camera.csv", [wavelen_cam.' response.'])Then, we execute the program as follows:
./bin/merge-exr \
data/cornell 400 50 output/CornellBox.exr \
data/cornell/camera.csv \
data/cornell/lens.csv \
data/cornell/F1.csv \
data/cornell/F2.csv \
data/cornell/F3.csv \
data/cornell/F4.csv \
data/cornell/F5.csv \
data/cornell/F6.csv \
data/cornell/F7.csvSpectrum to EXR executable (spectrum-to-exr) creates a 1x1px
spectral OpenEXR from a given spectrum.
It takes as arguments:
- A spectrum in CSV format (comma separated)
- Type of spectrum (either
reflectiveoremissive) - Output file
For example:
./bin/spectrum-to-exr data/D65.csv emissive output/D65.exrSplit channels executable (split-channels) splits a spectral EXR is
separate single monochromatic EXR files.
It takes as arguments:
- A spectral EXR file
- An output folder
For example:
./bin/split-channels Macbeth.exr output