A developer built Okmain, a Rust library (with Python bindings) for extracting visually pleasant dominant colors from images. The approach improves on the naive 1x1 resize trick by using k-means clustering in the Oklab perceptual color space instead of sRGB, applying center-weighted pixel prominence scoring, and optimizing for performance via downsampling, structure-of-arrays layout, and auto-vectorization. The post covers the algorithmic choices, performance tuning details, and a candid assessment of using Claude Opus via an agentic coding tool — finding it useful for boilerplate but unreliable for low-level SIMD-friendly code and clean abstractions.

8m read timeFrom dgroshev.com
Post cover image
Table of contents
Colour clusteringOklabCluster sortingPerformanceA tangent on LLMsGood for now
1 Comment

Sort: