Project

kolors

0.01
No commit activity in last 3 years
No release in over 3 years
Uses KMeans clustering and the L*A*B* colorspace to extract "approximate human vision" dominant colors from an image. Optionally, use Euclidean Distance to map those dominant colors into preferred "color bins" for a search index facet-by-color solution.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Kolors

Gem Version Code Climate

Uses the LAB* colorspace to extract "approximate human vision" dominant colors from an image. Optionally, map those dominant colors into preferred "color bins" for a search index facet-by-color solution.

LARGELY based off the neat work of the Miro gem. If you want faster, RGB-based dominant color extraction, use Miro.

Dependencies

Requires Imagemagick. On OSX use homebrew to install: brew install imagemagick

Installation

$ gem install kolors

Usage

require 'kolors'

# Use path to a local image or URL for remote image
kolors = Kolors::DominantColors.new('../colors/images/QFZMF57HPHVGJ8Z_thumb.png')
 
# Non-clustered - Color pixel count percentages
kolors.color_bins_result
 => [{"Moss"=>31.785714285714285}, {"Asparagus"=>22.658730158730158}, {"Aluminum"=>7.420634920634921}, {"Tungsten"=>5.396825396825397}, {"Magnesium"=>4.821428571428572}, {"Iron"=>4.424603174603175}, {"Steel"=>4.067460317460317}, {"Silver"=>3.8293650793650795}, {"Tin"=>3.7896825396825395}, {"Mercury"=>3.6904761904761907}, {"Nickel"=>3.5515873015873014}, {"Lead"=>2.380952380952381}, {"Snow"=>2.0634920634920633}, {"Licorice"=>0.11904761904761905}]
 

TODOS

  1. Simplify configuration of "color bins" for facet-by-color mapping

Thanks

  • Nate Vack for help getting this off of the ground.
  • Culley Smith for assistance in refactoring towards parallelization.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request