nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
color.hpp File Reference

Colour-space conversions, Lab helpers, colormaps. More...

#include <memory_resource>
#include <nk/value/value.hpp>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

void nk::image::imsplit (const Value &I, std::vector< Value > &planes, std::pmr::memory_resource *mr=nullptr)
 Split a multi-plane image into per-plane Values (imsplit(I, planes)).
Value nk::image::rgb2hsv (const Value &x, std::pmr::memory_resource *mr=nullptr)
 RGB → HSV (hsv = rgb2hsv(rgb)).
Value nk::image::hsv2rgb (const Value &x, std::pmr::memory_resource *mr=nullptr)
 HSV → RGB (inverse of rgb2hsv).
Value nk::image::rgb2ycbcr (const Value &x, std::pmr::memory_resource *mr=nullptr)
 RGB → YCbCr (BT.601) (ycbcr = rgb2ycbcr(rgb)).
Value nk::image::ycbcr2rgb (const Value &x, std::pmr::memory_resource *mr=nullptr)
 YCbCr → RGB (inverse of rgb2ycbcr).
Value nk::image::rgb2ntsc (const Value &x, std::pmr::memory_resource *mr=nullptr)
 RGB → NTSC YIQ (yiq = rgb2ntsc(rgb)).
Value nk::image::ntsc2rgb (const Value &x, std::pmr::memory_resource *mr=nullptr)
 NTSC YIQ → RGB (inverse of rgb2ntsc).
Value nk::image::rgb2xyz (const Value &x, std::pmr::memory_resource *mr=nullptr)
 sRGB → CIE XYZ (D65) (xyz = rgb2xyz(rgb)).
Value nk::image::xyz2rgb (const Value &x, std::pmr::memory_resource *mr=nullptr)
 CIE XYZ → sRGB (inverse of rgb2xyz).
Value nk::image::rgb2lab (const Value &x, std::pmr::memory_resource *mr=nullptr)
 sRGB → CIE L*a*b* (D65) (lab = rgb2lab(rgb)).
Value nk::image::lab2rgb (const Value &x, std::pmr::memory_resource *mr=nullptr)
 CIE L*a*b* → sRGB (inverse of rgb2lab).
Value nk::image::rgb2lightness (const Value &RGB, std::pmr::memory_resource *mr=nullptr)
 Lightness L* (L = rgb2lightness(RGB)).
std::pair< Value, Value > nk::image::cmunique_xm (const Value &X, const Value &MAP, std::pmr::memory_resource *mr=nullptr)
 Eliminate duplicate colors in colormap; convert grayscale or RGB to indexed ([Y, newmap] = cmunique(...)).
std::pair< Value, Value > nk::image::cmunique_rgb (const Value &RGB, std::pmr::memory_resource *mr=nullptr)
std::pair< Value, Value > nk::image::cmunique_i (const Value &I, std::pmr::memory_resource *mr=nullptr)
std::pair< Value, Value > nk::image::rgb2ind_inmap (const Value &RGB, const Value &cmap, std::pmr::memory_resource *mr=nullptr)
 RGB → indexed image with a fixed colormap ([ind, cmap] = rgb2ind(RGB, cmap)).
Value nk::image::xyz2lab (const Value &x, std::pmr::memory_resource *mr=nullptr)
 CIE XYZ → CIE L*a*b* (D50 ICC reference white).
Value nk::image::lab2xyz (const Value &x, std::pmr::memory_resource *mr=nullptr)
 CIE L*a*b* → CIE XYZ (inverse of xyz2lab).
Value nk::image::lab2double (const Value &lab, std::pmr::memory_resource *mr=nullptr)
 Cast Lab image to DOUBLE (labd = lab2double(lab)).
Value nk::image::lab2single (const Value &lab, std::pmr::memory_resource *mr=nullptr)
 Cast Lab image to SINGLE (labs = lab2single(lab)).
Value nk::image::lab2uint8 (const Value &lab, std::pmr::memory_resource *mr=nullptr)
 Cast Lab image to UINT8 (labu = lab2uint8(lab)).
Value nk::image::lab2uint16 (const Value &lab, std::pmr::memory_resource *mr=nullptr)
 Cast Lab image to UINT16 (labu = lab2uint16(lab)).
Value nk::image::colorgradient (const Value &C, const Value &w, int n, std::pmr::memory_resource *mr=nullptr)
 Smooth colormap through K anchor colours (M = colorgradient(C, w, n)).
Value nk::image::wavelength2rgb (const Value &wavelength, const std::string &out_class, double gamma, std::pmr::memory_resource *mr=nullptr)
 Wavelength → RGB (Bruton 1996) (RGB = wavelength2rgb(wavelength, class, gamma)).
Value nk::image::colorangle (const Value &rgb1, const Value &rgb2, std::pmr::memory_resource *mr=nullptr)
 Angle between two RGB colours (theta = colorangle(rgb1, rgb2)).
Value nk::image::gray_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Grayscale colormap (map = gray(n)).
Value nk::image::hot_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Black-red-yellow-white colormap (map = hot(n)).
Value nk::image::cool_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Cyan → magenta colormap (map = cool(n)).
Value nk::image::spring_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Magenta → yellow colormap (map = spring(n)).
Value nk::image::summer_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Green → yellow colormap (map = summer(n)).
Value nk::image::autumn_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Red → yellow colormap (map = autumn(n)).
Value nk::image::winter_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Blue → cyan-ish colormap (map = winter(n)).
Value nk::image::copper_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Copper-tinted colormap (map = copper(n)).
Value nk::image::pink_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Pastel-pink colormap (map = pink(n)).
Value nk::image::hsv_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Hue-rotation colormap (map = hsv(n)).
Value nk::image::flag_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Cyclic red/white/blue/black colormap (map = flag(n)).
Value nk::image::prism_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Cyclic 6-row rainbow palette (map = prism(n)).
Value nk::image::lines_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Axes-color-order palette (map = lines(n)).
Value nk::image::bone_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 Grayscale-with-blue-tint colormap (map = bone(n)).
Value nk::image::white_cmap (int n, std::pmr::memory_resource *mr=nullptr)
 All-ones colormap (map = white(n)).
Value nk::image::rgb2lin (const Value &A, std::pmr::memory_resource *mr=nullptr)
 sRGB → linear RGB gamma inverse (B = rgb2lin(A)).
Value nk::image::lin2rgb (const Value &A, std::pmr::memory_resource *mr=nullptr)
 Linear RGB → sRGB gamma forward (B = lin2rgb(A)).
Value nk::image::xyz2double (const Value &xyz, std::pmr::memory_resource *mr=nullptr)
 XYZ → DOUBLE (xyzd = xyz2double(xyz)).
Value nk::image::xyz2uint16 (const Value &xyz, std::pmr::memory_resource *mr=nullptr)
 XYZ → UINT16 ICC encoding (xyzu16 = xyz2uint16(xyz)).
Value nk::image::brighten (const Value &map, double beta, std::pmr::memory_resource *mr=nullptr)
 Gamma-adjust a colormap (rmap = brighten(map, beta)).
Value nk::image::contrast (const Value &x, int m, std::pmr::memory_resource *mr=nullptr)
 Histogram-equalising gray colormap (cmap = contrast(x, m)).
Value nk::image::rgbwide2ycbcr (const Value &RGB, int bits_per_sample, std::pmr::memory_resource *mr=nullptr)
 BT.2020 / BT.2100 wide-gamut RGB → YCbCr (ycbcr = rgbwide2ycbcr(RGB, bps)).
Value nk::image::ycbcr2rgbwide (const Value &YCBCR, int bits_per_sample, std::pmr::memory_resource *mr=nullptr)
 BT.2020 / BT.2100 wide-gamut YCbCr → RGB (rgb = ycbcr2rgbwide(YCBCR, bps)).
Value nk::image::imcolordiff (const Value &I1, const Value &I2, const std::string &standard, bool is_input_lab, double kL, double kC, double kH, double K1, double K2, std::pmr::memory_resource *mr=nullptr)
 CIE94 / CIEDE2000 colour difference (dE = imcolordiff(I1, I2, ...)).
Value nk::image::deltaE (const Value &I1, const Value &I2, bool isInputLab, std::pmr::memory_resource *mr=nullptr)
 CIE76 colour difference (delE = deltaE(I1, I2, isInputLab)).
Value nk::image::whitepoint (const std::string &illuminant, std::pmr::memory_resource *mr=nullptr)
 CIE reference-illuminant tristimulus (wp = whitepoint(illuminant)).
Value nk::image::cmap2gray (const Value &cmap, std::pmr::memory_resource *mr=nullptr)
 RGB colormap → grayscale colormap (gmap = cmap2gray(cmap)).
Value nk::image::illumwhite (const Value &A, double P, const Value &mask, std::pmr::memory_resource *mr=nullptr)
 White-Patch illuminant estimate (illum = illumwhite(A [, P] [, 'Mask', M])).
Value nk::image::illumpca (const Value &A, double P, const Value &mask, std::pmr::memory_resource *mr=nullptr)
 PCA-based illuminant estimate (illum = illumpca(A [, P] [, 'Mask', M])).
Value nk::image::illumgray (const Value &A, const std::vector< double > &P, const Value &mask, std::pmr::memory_resource *mr=nullptr)
 Grey-World illuminant estimate (illum = illumgray(A [, P] [, 'Mask', M])).
Value nk::image::label2rgb (const Value &L, const Value &cmap, const Value &background, std::pmr::memory_resource *mr=nullptr)
 Colourise a labelled image (RGB = label2rgb(L, cmap, background)).
Value nk::image::imfuse (const Value &A, const Value &B, const std::string &method, const std::string &scaling, const Value &channels, std::pmr::memory_resource *mr=nullptr)
 Composite two images for visual comparison (C = imfuse(A, B, method, ...)).
Value nk::image::tonemap (const Value &HDR, double lremap_lo, double lremap_hi, double saturation, int ntilesR, int ntilesC, std::pmr::memory_resource *mr=nullptr)
 Render high-dynamic-range image for low-dynamic-range display (RGB = tonemap(HDR, ...)).
Value nk::image::labeloverlay (const Value &A, const Value &L, const Value &colormap, const std::string &color_assignment, const Value &included_labels, double transparency, std::pmr::memory_resource *mr=nullptr)
 Overlay a label / mask / categorical-index image on a 2-D base (B = labeloverlay(A, L, ...)).
Value nk::image::chromadapt (const Value &A, const Value &illuminant, const std::string &method, const std::string &color_space, std::pmr::memory_resource *mr=nullptr)
 Chromatic adaptation for white-balance correction (B = chromadapt(A, illuminant, ...)).
Value nk::image::rgbwide2xyz (const Value &RGB, int bits_per_sample, const std::string &color_space, const std::string &linearization, std::pmr::memory_resource *mr=nullptr)
 Narrow-range wide-gamut RGB → CIE 1931 XYZ (XYZ = rgbwide2xyz(RGB, BPS, ...)).
Value nk::image::xyz2rgbwide (const Value &XYZ, int bits_per_sample, const std::string &color_space, const std::string &linearization, std::pmr::memory_resource *mr=nullptr)
 CIE 1931 XYZ → narrow-range wide-gamut RGB (RGB = xyz2rgbwide(XYZ, BPS, ...)).
Value nk::image::demosaic (const Value &I, const std::string &sensorAlignment, int bitsPerSample=0, std::pmr::memory_resource *mr=nullptr)
 Convert a Bayer-encoded mosaic to a truecolor RGB image (RGB = demosaic(I, sensorAlignment, BitsPerSample=bps)).
Value nk::image::raw2planar (const Value &cfa, std::pmr::memory_resource *mr=nullptr)
 Deinterleave a Bayer CFA mosaic into its four sensor planes (P = raw2planar(cfa)).
Value nk::image::planar2raw (const Value &I, std::pmr::memory_resource *mr=nullptr)
 Re-interleave 4 sensor planes into a full Bayer CFA mosaic (cfa = planar2raw(I)).

Detailed Description

Colour-space conversions, Lab helpers, colormaps.

Image shape convention. Most colour-space conversions accept either an H × W × 3 image or an N × 3 colormap (rows = pixels, cols = channels).

Output class. rgb2* / *2rgb / rgb2lab / lab2rgb / rgb2xyz / xyz2rgb return DOUBLE.

Integer input. When the input is integer-typed, values are rescaled by the class range first; double / single inputs in [0, 1] are taken at face value.

Definition in file color.hpp.