Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
color_vocabulary.c File Reference
#include "common/color_vocabulary.h"
#include "common/utility.h"
#include "system/macros.h"
#include <glib/gi18n.h>
+ Include dependency graph for color_vocabulary.c:

Go to the source code of this file.

Macros

#define LCH_HUE_SECTORS   15
 
#define LCH_LIGHTNESS_SECTORS   5
 

Functions

static range_t _compute_range (const gaussian_stats_t stats, const float factor)
 
char * _get_ethnicity_name (const ethnicities_t index)
 
skin_color_t get_skin_color (const size_t index)
 
char * Lch_to_color_name (dt_aligned_pixel_t color)
 Name the colour at color in plain language, e.g. "salmon" or "olive drab".
 
void get_skin_tones_range ()
 

Variables

static const char *const _lch_color_names [15][5]
 

Macro Definition Documentation

◆ LCH_HUE_SECTORS

#define LCH_HUE_SECTORS   15

Hue sectors of 24 degrees, read at chroma 80-100.

Definition at line 189 of file color_vocabulary.c.

◆ LCH_LIGHTNESS_SECTORS

#define LCH_LIGHTNESS_SECTORS   5

Lightness sectors of 20 %.

Definition at line 192 of file color_vocabulary.c.

Function Documentation

◆ _compute_range()

static range_t _compute_range ( const gaussian_stats_t  stats,
const float  factor 
)
static

◆ _get_ethnicity_name()

char * _get_ethnicity_name ( const ethnicities_t  index)

◆ get_skin_color()

skin_color_t get_skin_color ( const size_t  index)

◆ get_skin_tones_range()

◆ Lch_to_color_name()

char * Lch_to_color_name ( dt_aligned_pixel_t  color)

Name the colour at color in plain language, e.g. "salmon" or "olive drab".

Classifies by hue and lightness against a 15 x 5 grid of names, after two special cases: a chroma below 2.0 is "gray", and a colour falling inside the measured spread of any reference skin tone is named as such instead ("average Thai skin tone"), listing every ethnicity whose range it matches, one per line.

Parameters
colorCIE Lab 1976 turned into polar coordinates (Lch), as produced by dt_Lab_2_LCH(): L in percent, chroma, and hue NORMALIZED to [0, 1] – not degrees. Passing degrees puts every lookup out of the table's domain.
Returns
a newly-allocated, translated, human-readable name. The caller owns it and must g_free() it. Never NULL: a colour outside the table's domain gives "color not found" rather than a NULL a "%s" would then read.
Note
Ownership used to depend on which branch answered – the skin-tone path returned an allocated string while every other path returned a static literal, behind a const char * that told the caller neither. The one call site leaked whenever a skin tone matched. Allocating on every path is what makes the contract statable.

Definition at line 224 of file color_vocabulary.c.

References _compute_range(), _get_ethnicity_name(), _lch_color_names, skin_color_t::a, skin_color_t::b, color, dt_util_dstrcat(), skin_color_t::ethnicity, ETHNIE_END, FALSE, get_skin_color(), IS_NULL_PTR, skin_color_t::L, L, Lab, LCH_HUE_SECTORS, LCH_LIGHTNESS_SECTORS, out, SKINS, and TRUE.

Referenced by _sample_tooltip_callback().

Variable Documentation

◆ _lch_color_names

const char* const _lch_color_names[15][5]
static
Initial value:
= {
{ N_("deep purple"), N_("fuchsia"), N_("medium magenta"), N_("violet pink"), N_("plum violet") },
{ N_("dark red"), N_("red"), N_("crimson"), N_("salmon"), N_("pink") },
{ N_("maroon"), N_("dark orange red"), N_("orange red"), N_("coral"), N_("khaki") },
{ N_("brown"), N_("chocolate"), N_("dark gold"), N_("gold"), N_("sandy brown") },
{ N_("dark green"), N_("dark olive green"), N_("olive"), N_("khaki"), N_("beige") },
{ N_("dark green"), N_("forest green"), N_("olive drab"), N_("yellow green"), N_("pale green") },
{ N_("dark green"), N_("green"), N_("forest green"), N_("lime green"), N_("pale green") },
{ N_("dark sea green"), N_("sea green"), N_("teal"), N_("light sea green"), N_("turquoise") },
{ N_("dark slate gray"), N_("light slate gray"), N_("dark cyan"), N_("aqua"), N_("cyan") },
{ N_("navy blue"), N_("teal"), N_("dark cyan"), N_("deep sky blue"), N_("aquamarine blue") },
{ N_("dark blue"), N_("medium blue"), N_("azure blue"), N_("deep sky blue"), N_("aqua") },
{ N_("dark blue"), N_("medium blue"), N_("azure blue"), N_("deep sky blue"), N_("aqua") },
{ N_("dark blue"), N_("medium blue"), N_("blue"), N_("light sky blue"), N_("light blue") },
{ N_("indigo"), N_("dark violet"), N_("blue violet"), N_("violet"), N_("plum") },
{ N_("purple"), N_("dark magenta"), N_("magenta"), N_("violet"), N_("lavender") },
}

Definition at line 206 of file color_vocabulary.c.

Referenced by Lch_to_color_name().