Image Color Palette Extractor (K-Means Clustering)
Extract the top 3–8 dominant HEX, RGB, and HSL colors from any image in Canvas with WCAG accessibility contrast ratios.
Clustering pixels with K=5 extracts balanced primary, secondary, and accent colors cleanly; for UI text, WCAG 2.1 AA requires at least 4.5:1 contrast (3.0:1 for large headings ≥18pt).
What This Calculator Can Do & Ideal Use Cases
Best for: Best for UI/UX designers, brand creators, and frontend developers extracting WCAG-checked color themes straight from photos.
Clusters sampled HTML5 Canvas pixels via farthest-first K-Means++ into 3 to 8 dominant tones
Outputs exact HEX, RGB, HSL coordinates, pixel coverage percentages, and ranked order
Calculates real-time WCAG contrast ratios of every extracted swatch against white and black text
Copies ready-to-paste CSS :root custom property palettes in one click without server uploads
K-Means Color Quantization & WCAG 2.1 Contrast Benchmarks
Evaluating extracted HEX/RGB/HSL brand swatches against accessible typography contrast thresholds on white and dark surfaces.
WCAG Level / Use
Normal Text Contrast
Large Text Contrast
UI Component Use
WCAG AA Minimum
≥ 4.5 : 1
≥ 3.0 : 1
Buttons, body copy, links
WCAG AAA Enhanced
≥ 7.0 : 1
≥ 4.5 : 1
Long-form reading & finance
Decorative Accent (<3.0)
Avoid on text
Avoid on text
Borders, badges, subtle fills
Expert Tip: Run K=5 first to capture core brand harmony, then test WCAG contrast badges directly against white and black before copying the CSS variables.
K-Means++ Color Extraction & WCAG Contrast Guide
Sampling Canvas pixel RGB vectors into K clusters extracts dominant brand hues along with WCAG 2.1 luminance contrast ratios.
Best when using this tool: Choose this extractor to sample an image in Canvas and extract 3–8 dominant brand colors with HEX, HSL, and WCAG contrast scores.