rgb#

named_arrays.colorsynth.rgb(spd, wavelength=None, axis=None, spd_min=None, spd_max=None, spd_norm=None, wavelength_min=None, wavelength_max=None, wavelength_norm=None)#

A thin wrapper around colorsynth.rgb() for named arrays.

Parameters:
  • spd (AbstractArray) – A spectral power distribution to convert to a RGB array.

  • wavelength (None | AbstractScalar) – The wavelength coordinates corresponding to the spectral power distribution. If None (the default), the wavelength is assumed to be evenly sampled over the human visible range.

  • axis (None | str) – The logical axis corresponding to changing wavelength. If None (the default), spd must be one-dimensional.

  • spd_min (None | int | float | complex | ndarray | Quantity | AbstractArray) – The value of the spectral power distribution representing minimum intensity

  • spd_max (None | int | float | complex | ndarray | Quantity | AbstractArray) – The vale of the spectral power distribution representing maximum intensity

  • spd_norm (None | Callable) – An optional function that transforms the spectral power distribution values before mapping to RGB.

  • wavelength_min (None | int | float | complex | ndarray | Quantity | AbstractScalar) – The wavelength value that is mapped to the minimum wavelength of the human visible color range, 380 nm.

  • wavelength_max (None | int | float | complex | ndarray | Quantity | AbstractScalar) – The wavelength value that is mapped to the maximum wavelength of the human visible color range, 700 nm

  • wavelength_norm (None | Callable) – An optional function to transform the wavelength values before they are mapped into the human visible color range.

Return type:

AbstractArray

See also

colorsynth.rgb()

Equivalent function for instances of numpy.ndarray.

Examples

Plot the color of a random 3d cube

import matplotlib.pyplot as plt
import named_arrays as na

# Define a random 3d cube
a = na.random.uniform(
    low=0,
    high=1,
    shape_random=dict(x=16, y=16, wavelength=11)
)

# Compute the RGB colors of the 3d cube
rgb = na.colorsynth.rgb(
    spd=a,
    axis="wavelength",
)

# Plot the RGB image
fig, ax = plt.subplots(constrained_layout=True)
na.plt.imshow(
    rgb,
    axis_x="x",
    axis_y="y",
    axis_rgb="wavelength",
    ax=ax,
);
../_images/named_arrays.colorsynth.rgb_0_0.png