colorsynth#

Create false-color images from spectral cubes.

colorsynth collapses the spectral axis of a numpy.ndarray into red, green, and blue channels that can be displayed on a computer monitor. The spectrum at every point is mapped into the human visible range, weighted by the CIE 1931 color-matching functions, integrated along the spectral axis, and converted to the sRGB color space, so that the shape of the spectrum controls the hue of each pixel and the total intensity controls its brightness.

The main entry points are colorsynth.rgb(), which converts a spectral cube into an RGB image that can be displayed with matplotlib.pyplot.imshow() or matplotlib.pyplot.pcolormesh(), and colorsynth.rgb_and_colorbar(), which additionally computes a 2D colorbar relating color to wavelength and intensity.

Functions

XYZ_from_xyY_cie(xyY[, axis])

Convert from a CIE \(xyY\) color space to a \(XYZ\) color space

XYZ_normalized(XYZ[, axis, axis_max])

Normalize the luminance of a vector in the CIE 1931 \(XYZ\) color space.

XYZcie1931_from_spd(spd, wavelength[, axis])

Calculate the CIE 1931 tristimulus values, \(XYZ\), for the given spectral power distribution.

color_matching_x(wavelength)

The CIE 1931 \(\overline{x}(\lambda)\) color matching function.

color_matching_xyz(wavelength[, axis])

The CIE 1931 \(\overline{x}(\lambda)\), \(\overline{y}(\lambda)\), and \(\overline{z}(\lambda)\) color matching functions.

color_matching_y(wavelength)

The CIE 1931 \(\overline{y}(\lambda)\) color matching function.

color_matching_z(wavelength)

The CIE 1931 \(\overline{z}(\lambda)\) color matching function.

colorbar(spd[, wavelength, axis, ...])

Calculate the colorbar corresponding to calling rgb() with these same arguments.

d65_standard_illuminant(wavelength)

Spectral power distribution (SPD) of the CIE standard illuminant D65, which corresponds to average midday light in Western/Northern Europe.

rgb(spd[, wavelength, axis, spd_min, ...])

Convert a given spectral power distribution into a RGB array that can be plotted with matplotlib.

rgb_and_colorbar(spd[, wavelength, axis, ...])

Convenience function that calls rgb() and colorbar() and returns the results as a tuple.

sRGB(XYZ[, axis])

Convert CIE 1931 tristimulus values, calculated using XYZcie1931_from_spd(), into the sRGB color space, the standard color space used on computer monitors.

xyY_from_XYZ_cie(XYZ[, axis])

Convert from a CIE \(XYZ\) color space to a \(xyY\) color space