Coder Social home page Coder Social logo

rgbanalyse's Introduction

RGBAnalyse

An RGB-HC histogram library for same-origin images

demonstrator gh-page: http://pomax.github.io/RGBAnalyse

Client-side installation: simply grab the library from the release directory on github, or use bower to install: bower install rgbanalyse.

Node package installation: npm install rgbanalyse.

API

The library sets up an object with the following properties/functions:

  • defaults - a settings object with default values as analysis options.
  • analyse(img,[options]) - performs image analysis on an image element, with optional tweaks.
  • computeHSL(R,G,B) - convert RGB to HSL (note this requires normalised RGB values).
  • computeRGB(H) - convert HSL (no S/L right now) to RGB, H in range [0,6.28].
  • analyse(img,[options]) - convert HSL to rgb (plain {r,g,b}, using range [0,255]).

The defaults object can be set prior to running analyses, and currently supports the following properties:

  • neutrals - 10 - integer from 0 to 255, indicating the how close together {r,g,b} coordinates must be to be considered neutral
  • smoothing - 5 - used to smooth the hue spectrum when determining dominant hues. (value is distance from mean)
  • distance - 10 - minimum distance between recording two hues to end up recorded as major hues (value can range from 0 to 628)

The analyse function returns a two property object. The first is the analysis property, which houses:

  • rgb - A 3 component object with the histographical data for r, g and b.
  • RGB - A 3 component object with the histographical data for R, G,a nd B.
  • hsl - An object with the histographical data for h, and .dominant, a sorted array of {H,strength} major hues.
  • average - the weighted averages for r, g, b, R, G, B, and h.
  • maxima - the absolute maxima for r, g, b, R, G, B, and h.

The second is the visualization property, available only when using the libary in the browser, which houses image source data-uris for:

  • histogram - a 256 x 256 combined rgb histogram
  • spectrum.histogram - a 360 x 200 hues histogram
  • spectrum.spectogram - a 360 x 50 spectrogram

LICNSE

This code is released as Public Domain code. In jurisdictions that do not recognise the public domain, this code is to be considered under an MIT license (http://opensource.org/licenses/MIT)

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.