# Kmeans Dominant Color Palette Extractor

> Extracts dominant brand color palettes from imagery using K-Means unsupervised color clustering in CIELAB space. Use when generating adaptive UI themes matching

- Skill: `bishnucd/kmeans-dominant-color-palette-extractor` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx get-skill add bishnucd/kmeans-dominant-color-palette-extractor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/bishnucd/kmeans-dominant-color-palette-extractor/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: Bishnucd (https://skillmd.com/u/bishnucd)
- Updated: 2026-12-03
- Page: https://skillmd.com/skills/bishnucd/kmeans-dominant-color-palette-extractor

---

---
name: kmeans-dominant-color-palette-extractor
description: Extracts dominant brand color palettes from imagery using K-Means unsupervised color clustering in CIELAB space. Use when generating adaptive UI themes matching hero images.
license: MIT
metadata:
  author: Community List Maintainers
  version: "1.0.0"
  source: "https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html"
---
# Kmeans Dominant Color Palette Extractor

## Overview
Extracting colors in RGB space fails because Euclidean distances do not match human color perception. Clustering pixel values in perceptually uniform CIELAB space extracts harmonious brand palettes.

## Operational Workflow

1. **Downsample image to 200x200 pixels and convert RGB pixel array to CIELAB color space.**:
   - Downsample image to 200x200 pixels and convert RGB pixel array to CIELAB color space.

2. **Fit K-Means clustering model specifying desired palette size (e.g., k=5 or k=8 clusters).**:
   - Fit K-Means clustering model specifying desired palette size (e.g., k=5 or k=8 clusters).

3. **Rank cluster centroids by pixel count to identify primary, secondary, and accent colors.**:
   - Rank cluster centroids by pixel count to identify primary, secondary, and accent colors.

4. **Convert centroid coordinates back to sRGB hex strings for dynamic CSS theme variable injection.**:
   - Convert centroid coordinates back to sRGB hex strings for dynamic CSS theme variable injection.

## Recommended Tools & Environments
- K-Means Clustering
- CIELAB Color Space
- Scikit-Learn
- UI Theming

## Verification & Execution Criteria
- Pre-execution validation verifies all prerequisites and inputs.
- Step-by-step progress logging confirms intermediate state transitions.
- Post-execution checks verify output integrity and clean exit codes.

