New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

colorfulness

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colorfulness

Colorfulness algorithm inspired from Datta R., Joshi D., Li J., Wang J.Z.: Studying aesthetics in photographic images using a computational approach. ECCV (2006)

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Colorfulness

Node.js implementation of colorfulness using node-opencv binder for OpenCV.

  • From Rubner 2000, EMD is a good way to compare 2 images
  • From Datta 2006 has used a "perfectly colored" image BGR distribution to compare image with EMD This is what they called the colorfulness measure.

Prerequisites

You will need to make node-opencv work on your local machine, so havind, opencv, node, npm.

Histograms calculation

Which image is the most colorfull ? This library will give you the answer in node.js !

Pre-requisites

  • opencv

Installation

npm install colorfulness

Example

var colorfulness = require('colorfulness');

colorfulness("example/image.png", function(err, res){  
  // res is a number of colorfullness between 0 (not colorfull) and 1 (colorfull)
});

// or with open cv lib

var cv = require("opencv");
cv.readImage("example/image.png", function(err, im){
  if(err){
    //handle error
  }

  colorfulness({
    image : im
  }, function(err, res){  
    // res is a number of colorfullness between 0 (not colorfull) and 1 (colorfull)
  });
})


Test

npm test

Results

Images

FileImageColorfulness
mona.png60%
car1.jpg69%
stuff.png72%
neutral.png100%
amaro.png90%
FFFFFF.png56%
000000.png49%
00FFFF.png57%
Non-symetric of measure in BGR space

Remark : FFFFFF.png (white image) is more colorful than 000000.png (black image), it is because the cost function is done in the "LUV" color space.

To understand this, let's consider BGR-centers distance cost matrix in LUV_L2 distance space. To simplify my explanation i will use 2x2x2 = 8 BGR cubes (instead of 64 as used in the code);

Cubes centers are

Cube numberBGR center positionLUV center position
cube 0[64,64,64][69,97,139]
cube 1[64,64,192][117,166,160]
cube 2[64,192,64][176,57,211]
cube 3[64,192,192][193,100,212]
cube 4[192,64,64][90,92,46]
cube 5[192,64,192][128,136,68]
cube 6[192,192,64][182,61,129]
cube 7[192,192,192][198,97,139]

Matrix of distance in LUV space is looks like :

cube 0cube 1cube 2cube 3cube 4cube 5cube 6cube 7SUM
cube 00.000.440.690.740.490.510.610.664.14
cube 10.440.000.690.580.710.500.650.554.12
cube 20.690.690.000.240.970.870.420.444.31
cube 30.740.580.240.001.000.830.470.374.23
cube 40.490.710.971.000.000.320.650.734.87
cube 50.510.500.870.830.320.000.570.554.14
cube 60.610.650.420.470.650.570.000.213.58
cube 70.660.550.440.370.730.550.210.003.51

So pure "cube 0"-distribution (corresponding to FFFFFF image) will not be symetric with "cube 7"-distribution (corresponding to 000000 image).

Pure "cube 4"-distribution (corresponding to 00FFFF image), is even more colorful.

Keywords

FAQs

Package last updated on 05 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc