@duetds/date-picker
Version:
Duet Date Picker is an open source version of Duet Design Systemβs accessible date picker.
63 lines (38 loc) β’ 5.59 kB
Markdown
[](https://circleci.com/gh/obartra/ssim/tree/master) [](https://codeclimate.com/github/obartra/ssim/coverage) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/ssim.js)
# SSIM.JS
> Get a `0` to `1` score on how similar two images are
The closer [SSIM](https://en.wikipedia.org/wiki/Structural_similarity) is to `1` the higher the similarity. It correlates better with subjective ratings than other measures like [PSNR](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio) and [MSE](https://en.wikipedia.org/wiki/Mean_squared_error). 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
```shell
npm install ssim.js
```
You can also use the web version directly from [unpkg](https://unpkg.com)'s CDN: `https://unpkg.com/ssim.js@{{version}}/dist/ssim.web.js`.
## π Usage
Check out the [playground](https://ssim-comparison.gomix.me/) for node and web usage examples.
SSIM.js takes in 2 image buffers and optional options parameter. You can find all options available [here](https://github.com/obartra/ssim/wiki/Usage#options).
For examples on how to implement image loading strategies for both node and the web, check out [this wiki page](https://github.com/obartra/ssim/wiki/Node-and-Browsers).
```js
import ssim from "ssim.js";
const img1 = loadImage("./img1.jpg");
const img2 = loadImage("./img2.jpg");
const { mssim, performance } = ssim(img1, img2);
console.log(`SSIM: ${mssim} (${performance}ms)`);
```
## π Documentation
If you run into any issues or want a more info, check the [wiki](https://github.com/obartra/ssim/wiki).
The code is fully documented but feel free to create an issue [here](https://github.com/obartra/ssim/issues/new) if you have any questions.
## π Metrics
| Process | Status |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Versioning | [](https://github.com/semantic-release/semantic-release) [](http://commitizen.github.io/cz-cli/) |
| Dependencies | [](https://snyk.io/test/github/obartra/ssim) [](https://david-dm.org/obartra/ssim) |
## π‘ Credits
This project is a direct port of algorithms published by [Wang, et al. 2004](/assets/ssim.pdf) on "Image Quality Assessment: From Error Visibility to Structural Similarity". The original Matlab scripts are available [here](https://ece.uwaterloo.ca/~z70wang/research/iwssim/) with their datasets. To view the steps taken to validate `ssim.js` results, check the [wiki](https://github.com/obartra/ssim/wiki/Results-Validation).
The current (default) implementation uses the Weber algorithm, originally developed by Dan Weber, 2020 at [notatypical.agency](https://notatypical.agency/).