Add halogen-image module for image-to-theme extraction#19
Open
Add halogen-image module for image-to-theme extraction#19
Conversation
Enables theming from images (e.g., album art in music players) by extracting dominant colors and mapping them to HalogenThemeSpec roles. Uses HCT-space k-means clustering for perceptually accurate color extraction (~0.8ms). Two paths: algorithmic (instant, offline via toSpec()) or LLM-enhanced (mood-aware typography/shapes via toHint()). Coil 3 integration for URL-based image loading with platform-specific pixel extraction. API: engine.resolveImage(url, imageLoader, context) — Coil URL path engine.resolveImage(key, pixels, width, height) — raw pixels path ImageQuantizer.extract(pixels, w, h) — standalone extraction DominantColors.toSpec() / .toHint() — conversion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
halogen-imageKMP module that extracts dominant colors from images and maps them to Halogen themestoSpec()— instant, no LLM) and LLM-enhanced (toHint()— mood-aware typography/shapes)API
Module structure
ImageQuantizer— histogram + HCT k-means clustering (subsamples to 16K pixels, 64 histogram entries, 10 iterations)ImageThemeExtractor— assigns extracted colors to pri/sec/ter/neutral roles by chroma/hue/tone heuristicsDominantColors— result type withtoSpec()andtoHint()conversionsEngineExtensions—resolveImage()overloads onHalogenEngineexpect/actualfor Coil image → ARGB pixel extractionPerformance
Tests
38 test cases across 3 files covering extraction algorithm, role assignment heuristics, round-trip validation through
ThemeExpander.expand().Test plan
./gradlew :halogen-image:jvmTest— all 38 tests pass./gradlew :halogen-image:testReleaseUnitTest— Android tests pass./gradlew :halogen-image:apiCheck— API surface validatedhalogen-core,halogen-engine)halogen-compose)🤖 Generated with Claude Code