Giter VIP home page Giter VIP logo

camalian's Introduction

Camalian

Gem Version Ruby Maintainability

Ruby gem to extract color palettes from images and play with their saturation

Installation

Add this line to your application's Gemfile:

gem 'camalian', '~> 0.2.0'

And then execute:

$ bundle

Or install it yourself as:

$ gem install camalian

Usage

image = Camalian::load('file_path')
colors = image.prominent_colors(15)
colors = colors.sort_similar_colors
colors.light_colors(0, 40)

You can find a working example with detail explanation and reference code here on this link. Here we will build a functional color based image search engine in Ruby on Rails.

NOTE: Since its a compute intensive operation so for production use its suggested to use under a background job and not within a request/response cycle.

Quantization Algorithms

Currently following algorithms are implemented.

Histogram

Its a most common algorithm for color quantization and used different bucket technique to group the colors together. You can read more about this technique here. It can be accessed by Camalian::QUANTIZATION_HISTOGRAM constant. This is used as default method as well.

K Means

This algorithm uses color distancing in RGB space to group the similar colors. You can learn more about this technique here. It can be accessed by Camalian::QUANTIZATION_K_MEANS constant.

Median Cut

This algorithm uses color highest color range to determine the median and split colors to groups. The output consists of average color of such color groups. Since these algorithm don't use actual colors and instead average, so you will may not exact matching pixel in the image. This algorithm is nice to be used with image compression, where similarity and compression is important than having same pixel colors. You can learn more about this technique here . It can be accessed by Camalian::QUANTIZATION_MEDIAN_CUT constant.

You can set default quantization method globally as:

Camalian.options[:quantization] = Camalian::QUANTIZATION_K_MEANS

or you can set at the time of extracting colors by.

image = Camalian::load('file_path')
colors = image.prominent_colors(15, quantization: Camalian::QUANTIZATION_K_MEANS)

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

camalian's People

Contributors

fschuindt avatar nazarhussain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

camalian's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.