Render Toolbox 3  v2.1
 All Functions Groups Pages
Functions
Readers

Read multi-spectral data from various image file formats. More...

Functions

imageData imageSize lens ReadDAT (filename)
 Get multispectral image data out of a .dat file from Stanford.
 
imageData imageSize wls ReadEXRs (imageDir, imageBase, S)
 Get multi-spectral image data out of some .exr files in a folder.
 
imageData imageSize wavelengths ReadMIF (filename)
 Get multispectral image data out of a .mif file from Stanford.
 
imageData wls S ReadMultispectralEXR (exrFile)
 Read an OpenEXR image with multiple spectral slices.
 
wavelengths magnitudes ReadSpectrum (spectrum)
 Get wavelengths and magnitudes from a spectrum string or text file.
 
filename WriteSpectrumFile (wavelengths, magnitudes, filename)
 Write a given spectral power distribution to a text file.
 

Detailed Description

Read multi-spectral data from various image file formats.

These functions read multi-spectral data from image files. Each one oparates on a particular image file format. They all return multi-spectral images with size [height, width, n], where n is the number of image spectral planes.

Function Documentation

imageData imageSize lens ReadDAT ( filename  )

Get multispectral image data out of a .dat file from Stanford.

Parameters
filenamestring file name (path optional) of the .dat file

Reads the given multi-spectral .dat file from filename. The .dat format is described by Andy Lin on the Stanford Vision and Imaging Science and Technology wiki. (If not, a description may be there soon.)

See the RenderToolbox3 wiki for more about image Spectrum Bands, and how RenderToolbox3 determines the spectral sampling of PBRT .dat files.

Returns a matrix of multispectral image data, with size [height width n], where height and width are image size in pixels, and n is the number of spectral planes.

Also returns the multispectral image dimensions [height width n].

If the given .dat file contains an optional lens description, also returns a struct of lens data with fields focalLength, fStop, and fieldOfView.

Usage: [imageData, imageSize, lens] = ReadDAT(filename)

imageData imageSize wls ReadEXRs ( imageDir  ,
imageBase  ,
 
)

Get multi-spectral image data out of some .exr files in a folder.

Parameters
imageDirstring folder name containing .exr files
imageBasestring prefix that all .exr file names start with
Smatrix specifying spectral plane wavelengths [start delta n]

Reads .exr files from the given imageDir. Each .exr file should contain a grayscale image. Each file should be named like "@a imageBase-LOW-HIGH.ext", where imageBase is a common prefix for all images, and LOW and HIGH are wavelengths that define a spectral band.

The S determines what file names to look for. S must be a [start delta n] description of a list of wavelengths.

Returns a matrix of multispectral image data, with size [height width n], where height and width are image size in pixels, and n is the number of spectral planes.

Also returns the multi-spectral image dimensions [height width n]. Also returns a matrix of length n that lists the wavelengths of all spectral planes in nanometers.

Usage: [imageData, imageSize, wls] = ReadEXRs(imageDir, imageBase, S)

imageData imageSize wavelengths ReadMIF ( filename  )

Get multispectral image data out of a .mif file from Stanford.

Parameters
filenamestring file name (path optional) of the .mif file

Reads the given multispectral .mif file from filename. The .mif format is described by Andy Lin on the Stanford Vision and Imaging Science and Technology wiki: http://white.stanford.edu/pdcwiki/index.php/PBRTFileFormat

Returns a matrix of multispectral image data, with size [height width n], where height and width are image size in pixels, and n is the number of spectral planes.

Also returns the multispectral image dimensions [height width n]. Also returns a matrix of length n that lists the wavelengths of all spectral planes in nanometers.

Usage: [imageData, imageSize, wavelengths] = ReadMIF(filename)

imageData wls S ReadMultispectralEXR ( exrFile  )

Read an OpenEXR image with multiple spectral slices.

Parameters
exrFilefile name or path of an OpenEXR file

Reads an OpenEXR image with an arbitrary number of spectral slices.

The given exrFile should be an OpenEXR multi-spectral data file, with color data stored as evenly spaced slices through the spectrum, not as RGB or RGBA. Each slice must have a name that identifies the wavelengths of that particular slice. The name should be formatted like this:

12.34-56.78nm

where "12.34" represents any decimal value for the low bound of the slice's spectrum band, and "56.78" represents any decimal value for the high bound. Both values should be in units of nanometers. The "nm" suffix is optional. Image slices with names that don't match this pattern will be ignored.

Returns an array of image data with size [height width n], where height and width are image sizes in pixels, and n is the number of spectral slices. The n slices will be sorted from low to high wavelength.

Also returns the list of n wavelengths, one for each spectral slice. The wavelength for each slice is taken as the mean of the low and high bounds The list of wavelengths will be sorted from low to high. See the RenderToolbox3 wiki for more about Spectrum Bands

Also returns a summary of the list of wavelengths in "S" format. This is an array with elements [start delta n].

Usage: [imageData, wls, S] = ReadMultispectralEXR(exrFile)

wavelengths magnitudes ReadSpectrum ( spectrum  )

Get wavelengths and magnitudes from a spectrum string or text file.

Parameters
spectrumstring or file name (path optional) with spectrum data

Scans the given spectrum for wavelength-magnitude pairs. spectrum may be a string or a spectrum data text file.

If spectrum is a string, it must contain wavelength:magnitude pairs, with spaces between pairs. For example:

300:0.1 550:0.5 800:0.9

where 300, 550, and 800 are wavelengths in namometers, and 0.1, 0.5, and 0.9 are magnutudes for each wavelength.

If spectrum is a file name, the file must contain wavelength-magnitude pairs, with new lines between paris. For example:

300 0.1
550 0.5
800 0.9

where 300, 550, and 800 are wavelengths in namometers, and 0.1, 0.5, and 0.9 are magnutudes for each wavelength.

Returns a 1 x n matrix of n wavelengths, and a corresponding 1 x n matrix of magnitudes.

Usage: [wavelengths, magnitudes] = ReadSpectrum(spectrum)

filename WriteSpectrumFile ( wavelengths  ,
magnitudes  ,
filename   
)

Write a given spectral power distribution to a text file.

Parameters
wavelengthsmatrix of spectrum sampling wavelengths
magnitudesmatrix of spectrum sample magnitudes
filenamename of a text file to create or replace

Writes the given wavelengths and magnitudes to a spectrum data text file, with the given filename.

The text file will contain a wavelength-magnitude pair on each line. This format is suitable for specifying spectra to PBRT or Mitsuba. For example:

300 0.1
550 0.5
800 0.9

where 300, 550, and 800 are wavelengths in namometers, and 0.1, 0.5, and 0.9 are magnutudes for each wavelength.

Returns the given filename, or a default file name if none was given.

Usage: filename = WriteSpectrumFile(wavelengths, magnitudes, filename)