130 out.
colors.reserve(cmap.size());
131 for (
const auto& c : cmap) {
133 c.r / 255.0f, c.g / 255.0f,
134 c.b / 255.0f, c.a / 255.0f);
154 size_t n = data.
size() /
static_cast<size_t>(channels);
156 for (
size_t i = 0; i < n; i++) {
157 float r = data[i * channels] / 255.0f;
158 float g = data[i * channels + 1] / 255.0f;
159 float b = data[i * channels + 2] / 255.0f;
160 float a = (channels >= 4) ? data[i * channels + 3] / 255.0f : 1.0f;
161 out.
colors.emplace_back(r, g, b, a);
298 const std::vector<float>& data,
302 const Color& nan_color =
Color{0.5f, 0.5f, 0.5f, 1.0f},
304 float hi_pct = 100.0f
345 const std::vector<std::vector<float>>& datasets,
346 const ColorMap& colormap,
349 const Color& nan_color = Color{0.5f, 0.5f, 0.5f, 1.0f},
351 float hi_pct = 100.0f,
352 bool global_range = false
ApplyColormapResult apply_colormap(const std::vector< float > &data, const ColorMap &colormap, float vmin, float vmax, const Color &nan_color, float lo_pct, float hi_pct)
Map a single vector of numeric data to RGBA colours using a colormap.
Result of apply_colormap() for a single dataset.
float data_min
The actual data range used for mapping (after winsorizing, or as explicitly set).
std::vector< Color > colors
Per-element RGBA colours, same order and length as the input data vector.
float raw_max
Raw finite maximum of the input data (before winsorizing).
float data_max
The actual data range used for mapping (after winsorizing, or as explicitly set).
size_t nan_count
Number of NaN / Inf values in the input data.
float winsor_hi
Upper percentile cutoff used for winsorizing.
float winsor_lo
Lower percentile cutoff used for winsorizing.
float raw_min
Raw finite minimum of the input data (before winsorizing).
Self-contained colormap — owns a colour lookup table and supports linearly interpolated sampling.
static ColorMap from_interleaved(const std::vector< uint8_t > &data, int channels=3)
Build a ColorMap from a flat interleaved RGB(A) byte array.
bool empty() const
True if the colormap has no entries.
static const ColorMap & viridis()
The Viridis perceptually-uniform sequential colormap (256 entries).
size_t size() const
Number of entries in the colormap.
Color sample(float t) const
Sample the colormap at a normalized position using linear interpolation.
static ColorMap from_uint8_colors(const std::vector< T > &cmap)
Build a ColorMap from a vector of scibar-style uint8_t RGBA colours.
std::vector< Color > colors
The colour lookup table entries in [0, 1] float RGBA.
An RGBA color with floating-point components.
Aggregate result of apply_colormap() for multiple datasets.
float pooled_data_max
Pooled effective data range (post-winsorizing) across all datasets.
float pooled_winsor_hi
Pooled upper percentile cutoff.
size_t total_nan_count
Total number of NaN / Inf values across all datasets.
float pooled_winsor_lo
Pooled lower percentile cutoff.
std::vector< ApplyColormapResult > per_dataset
One result per input dataset, in the same order.
float pooled_raw_max
Pooled raw finite maximum across all datasets.
float pooled_data_min
Pooled effective data range (post-winsorizing) across all datasets.
float pooled_raw_min
Pooled raw finite minimum across all datasets.
Fundamental types used throughout the scimesh rendering engine.