Every textile designer builds palettes from inspiration images — fashion photography, fabric swatches, nature shots, mood boards. Done manually with the eyedropper tool, this takes 20 minutes and produces inconsistent results. Done correctly with K-means clustering in LAB space, it takes 30 seconds and produces a palette that genuinely represents the source.
This guide covers the math behind proper palette extraction, the Pantone TCX mapping step that makes extracted colors production-ready, and the five mistakes that produce unusable palettes.
Why K-Means Clustering Wins
K-means is a clustering algorithm that groups pixels into K color groups (K = number of palette colors you want). Each cluster's center is one palette color. The algorithm:
- Start with K random color seeds in color space
- Assign every pixel to its nearest seed
- Move each seed to the average of its assigned pixels
- Repeat until seeds stop moving
The result: K colors that collectively best represent the image. Unlike manual eyedropper sampling, K-means finds actual color clusters rather than single pixel samples, so the palette reflects dominant trends rather than one designer's arbitrary picks.
The LAB Space Requirement
Running K-means in RGB is fast but produces perceptually wrong results. RGB Euclidean distance over-weights blue-green differences and under-weights neutral differences. Two pixels 20 units apart in RGB might look identical (if in dark neutrals) or dramatically different (if in saturated cyans).
LAB space fixes this. Equal distance in LAB equals equal perceived difference, because LAB is designed around human visual perception. K-means clustering in LAB groups pixels by how similar they actually look, not by their raw numeric similarity.
Every professional palette extraction runs in LAB. Tools that don't — including many free web-based extractors — produce palettes that look wrong for reasons users cannot quite articulate.
Extraction Workflow
- Load the source image. Ideally at original resolution; downsampling to 512×512 for clustering is fine and 10× faster.
- Convert to LAB color space. Every professional tool does this automatically.
- Filter out extreme lightness. Mask pixels with L < 10 (near-black) and L > 95 (near-white). These dominate averages without contributing useful palette info.
- Run K-means with K = 5 to 8. Lower for minimal palettes, higher for rich multi-color designs.
- Sort by dominance. Output palette ordered by cluster size (biggest cluster = most dominant color).
Pantone TCX Mapping
Extracted palette colors are arbitrary LAB values. For textile production, they need to map to specific Pantone TCX references (or approved CMYK builds). The mapping workflow:
- For each extracted color, calculate CIEDE2000 Delta E against every Pantone TCX library entry
- Take the lowest Delta E as the nearest match
- If Delta E ≤ 2, the match is commercially acceptable
- If Delta E 2–4, the match is close but may need spot-ink adjustment
- If Delta E > 4, no close Pantone exists — decide: accept CMYK reproduction, or specify custom spot ink
Our Color Matching tool runs K-means in LAB, filters extremes, and does Pantone TCX mapping in one pass, reporting Delta E for every match.
Common Extraction Mistakes
- Running K-means in RGB. Wrong color space, wrong distance metric, wrong results.
- Not filtering white and black. Palette becomes "white, black, gray, one real color."
- Extracting too many colors. 12-color palettes are unusable for most textile applications.
- Relying on image-compression artifacts. Heavily compressed JPGs have color noise that becomes cluster members.
- Skipping substrate testing. Extracted colors look different on cotton vs polyester vs silk.
Refining the Extracted Palette
Raw K-means output is the starting point, not the final palette. Typical refinement:
- Adjust saturation uniformly for a cohesive look
- Lighten or darken one accent color for visual hierarchy
- Replace one machine-selected color with a designer-chosen alternative
- Confirm final palette works across all intended substrates
The algorithm gets you to a defensible starting palette fast. The designer turns it into something production-ready.
Applications in Textile Workflow
- Season palette development — extract from trend mood boards, convert to Pantone, release to design team
- Brand color auditing — extract from existing brand photography, compare to stated brand colors, find drift
- Fabric photograph matching — scan a vintage fabric, extract palette, recreate for new production
- Colorway generation — one pattern, multiple palettes extracted from different source images
Related Reading
For the color-transfer step that applies an extracted palette to an existing design: Reinhard color transfer guide. For the Delta E tolerances that determine whether a Pantone mapping is acceptable: CIEDE2000 Delta E explained. For the complete color management framework: textile color management playbook.


