πŸ–ΌπŸ”¬ JavaScript Image Comparison
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github docs(README): Move README content to Wiki πŸ’Ί (#12) Oct 18, 2016
LICENSES feat(algorithm): Adds Bezkrovny's SSIM algorithm (#85) Jan 24, 2017
assets feat(ssim): Correct SSIM implementation πŸ“Έ (#2) Oct 5, 2016
ci test(perf): Improve logs for performance tests ⚑ (#79) Dec 30, 2016
generate feat(algorithm): Adds Bezkrovny's SSIM algorithm (#85) Jan 24, 2017
spec chore(dependencies): Update npm dependencies (#133) Nov 12, 2017
src chore(dependencies): Update npm dependencies (#133) Nov 12, 2017
.babelrc feat(Promise): Promise definition independent (#73) Dec 21, 2016
.codeclimate.yml feat(ssim): Correct SSIM implementation πŸ“Έ (#2) Oct 5, 2016
.doclets.yml feature(ssim): Not ready for consumption πŸ” Sep 21, 2016
.eslintignore test(web): Improves web tests πŸ’ͺ (#66) Dec 15, 2016
.eslintrc chore(update): Update deps, add yarn, prettier (#126) Sep 4, 2017
.gitignore chore(dependencies): Update npm dependencies (#133) Nov 12, 2017
.istanbul.yml build(CI): semantic release and immprove docs πŸ“™ (#14) Oct 20, 2016
.jsdoc feature(ssim): Not ready for consumption πŸ” Sep 21, 2016
.npmrc chore(package): Update dependencies and allow minor version automatic… Oct 26, 2016
CONTRIBUTING.md docs(contributing): πŸ“° Add contributing guide (#41) Nov 13, 2016
LICENSE Create LICENSE Nov 12, 2017
README.md chore(dependencies): Update npm dependencies (#133) Nov 12, 2017
circle.yml chore(dependencies): Update npm dependencies (#133) Nov 12, 2017
cli.js chore(dependencies): Update npm dependencies (#133) Nov 12, 2017
index.js feat(algorithm): Adds Bezkrovny's SSIM algorithm (#85) Jan 24, 2017
package.json chore(dependencies): Update npm dependencies (#133) Nov 12, 2017
version.js build(CI): semantic release and immprove docs πŸ“™ (#14) Oct 20, 2016
webpack.config.js feat(Promise): Promise definition independent (#73) Dec 21, 2016
webpack.config.web.js feat(build): Adds web build 🌐 Nov 27, 2016
webpack.config.web.test.js test(web): Improves web tests πŸ’ͺ (#66) Dec 15, 2016
yarn.lock chore(dependencies): Update npm dependencies (#133) Nov 12, 2017

README.md

CircleCI Test Coverage license

SSIM.JS

Get a 0 to 1 score on how similar two images are

The closer SSIM is to 1 the higher the similarity. It correlates better with subjective ratings than other measures like PSNR and MSE. For instance:

Original, MSE = 0, SSIM = 1 MSE = 144, SSIM = 0.988 MSE = 144, SSIM = 0.913
MSE = 144, SSIM = 0.840 MSE = 144, SSIM = 0.694 MSE = 142, SSIM = 0.662

Table extracted from http://www.cns.nyu.edu/~lcv/ssim/

πŸ–₯ Install

npm install ssim.js

This will install the node, web and CLI versions.

Install it globally (npm install -g) to make ssim available on your path.

You can also use the web version directly from unpkg's CDN: https://unpkg.com/ssim.js@{{semver}}.

πŸ“ Usage

Playground for Node and Web versions.

Node:

import ssim from 'ssim.js';

ssim('./img1.jpg', './img2.jpg')
  .then(({ mssim, performance }) => console.log(`SSIM: ${mssim} (${performance}ms)`))
  .catch(err => console.error('Error generating SSIM', err));

Browser:

  <script src="https://unpkg.com/ssim.js@^2.0.0"></script>
  <script>
    ssim('/img1.jpg', '/img2.jpg')
      .then(function(out) {
        console.log('SSIM:', out.mssim, '(', out.performance, 'ms)');
      })
      .catch(function(err) {
        console.error('Error generating SSIM', err);
      });
  </script>

CLI:

$ ./node_modules/.bin/ssim ./img1.jpg ./img2.jpg

πŸ“– Documentation

If you run into any issues or want a more info, check the wiki.

The code is fully documented and a hosted version is available here.

🏁 Metrics

Process Status
Code Quality Code Climate Issue Count
Versioning semantic-release Commitizen friendly npm Greenkeeper badge
Dependencies Known Vulnerabilities DavidDM
Documentation InchCI
Environments Sauce Test Status

Sauce Browser Matrix

πŸ’‘ Credits

This project is a direct port of algorithms published by Wang, et al. 2004 on "Image Quality Assessment: From Error Visibility to Structural Similarity". The original Matlab scripts are available here with their datasets. To view the steps taken to validate ssim.js results, check the wiki.