Show HN: Simple algorithm and color space to generate diverse skin tones
Frustrated by the limited options for diverse skin tones in digital art, a developer created an algorithm and color space to make inclusive representation easier. This technical deep dive explains how Principal Component Analysis (PCA) and manual function fitting were used to map the complex reality of human skin onto a simple, adjustable sphere. The project offers a practical solution for game developers and artists while openly acknowledging its limitations and the broader social context of color representation.
The Lowdown
The author presents an innovative solution to the long-standing challenge of digitally representing the vast spectrum of human skin tones, a problem often addressed inadequately by existing tools. Their project, named "What Colors Are We?", introduces a novel color space and a simple algorithm designed to generate plausible, diverse skin tones for applications like character creators and digital art, aiming for a middle ground between a few preset options and 16 million choices.
- The Problem: Existing digital color tools frequently offer limited or unrealistic skin tone options, leading to the exclusion or misrepresentation of many individuals. Skin tones are complex, influenced by biology, health, and environmental factors, making simplified digital representation difficult.
- The Goal: To define an inclusive range of skin colors within the RGB space, developing "good enough" equations to make this range easily usable across various contexts, with an emphasis on pragmatism over absolute scientific rigor.
- Methodology: The process began with manually labeling a dataset of plausible skin tones in RGB. This data, initially forming a "banana-shaped" curve, was then subjected to Principal Component Analysis (PCA) to transform it into a more orthogonal "XYZ space." The final step involved manually fitting a spherical function (R² = t² + u² + v²) to this transformed data using Desmos 3D, creating a new "TUV space" and deriving equations to translate between TUV and RGB.
- Results & Picker UI: The project yields a functional color space, a custom color picker, and a procedural generation algorithm. The T, U, and V components of the new color space intuitively control aspects like "Deep/Fair," "Flushed/Ochre," and "Cool/Warm," a direct outcome of PCA's ability to align data along meaningful axes. The R² value in the spherical equation acts as a radius, allowing users to control the diversity and realism of generated tones from subtle variations to more cartoonish ranges.
- Limitations & Social Context: The author transparently discusses the work's inherent limitations, including the simplification of complex biological skin variations, subjective biases in data labeling, and display inconsistencies. A significant "Humanities Intermission" section is included, emphasizing the social context of skin color, addressing issues of colorism and lack of representation, and linking to works by creators like Nyma Tang and Angelica Dass.
- Future Work: The author outlines potential improvements, such as refining the space with more precise, expert-labeled data, modeling specific skin conditions (e.g., jaundice, freckles), and technical optimizations like symbolic regression or exploring different initial color spaces for PCA.
Ultimately, the author is pleased with the practical utility of their solution for digital artists and developers, inviting feedback and collaboration to further refine this inclusive color space.