Skip to content

djui/dominance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dominance

A Clojure library to extract the dominant color in an image. The algorithm is optimized for graphics like podcast covers, rather than pictures.

Background

Lately many mobile clients exploit the feature to tint their UI elements color which is dominant in the podcast or album cover. This library tries to resample this feature.

Usage

To see an examplary usage, run the following command:

$ lein run > result.html
$ open result.html

This will create the following page.

To use the library in your application, use the following API:

$ lein repl
example=> (require '[dominance.core :as dominance]
                   '[clojure.java.io :as io])
nil

;; Extract a palette of maximum 5 most dominant colors
example=> (->> "resources/01.jpg" io/file dominance/palette (map :hex))
("#CEDCD9" "#DF827D")

;; Extract the most dominant color
example=> (->> "resources/01.jpg" io/file dominance/color :hex)
("#CEDCD9")

;; Extract the most dominant background and foreground colors
example=> (->> "resources/01.jpg" io/file dominance/bg-fg (map :hex))
("#CEDCD9" "#DF827D")

Future work

  • Replace k-Means Clustering algorithm with Connected-Components Labeling algorithm.

Credits

Courtesy to the following authors:

License

Copyright © 2013 Uwe Dauernheim uwe@dauernheim.net

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Find dominant colors in an image

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published