@dannadori/image-score-js

This package provide image scoring functions.

Usage no npm install needed!

<script type="module">
  import dannadoriImageScoreJs from 'https://cdn.skypack.dev/@dannadori/image-score-js';
</script>

README

image-score-js

This package provide image scoring functions.

Currentry provided functions is belows.

  • PSNR
  • SSIM

This package include three edition. The file size is different, so please choose one depneding on your usecase.

  • WASM
  • WASM SIMD
  • WASM and WASM SIMD

Sample source code is here

Installation and basic usage

Instalattion

npm install @dannadori/imager-score-js

Importing to your application

  1. WASM edition
import { ImageScoreWasm } from '@dannadori/image-score-js/dist/image-score-wasm'
  1. WASM SIMD edition
import { ImageScoreWasmSimd } from '@dannadori/image-score-js/dist/image-score-wasm-simd'

  1. WASM and WASM SIMD edition
import { ImageScore } from '@dannadori/image-score-js'

Initialize

const is = new ImageScore() // If you use othere edition, you should change
is.init()

Functions

PSNR and SSIM

PSNR and SSIM are implemented according to this article

At first you put two image(HTMLCanvasElement) by setImage, then call psnr or mssim.

setImage: (image1: HTMLCanvasElement, image2: HTMLCanvasElement, params: ImageScoreParams) => void;
psnr: (params: ImageScoreParams) => number;
mssim: (params: ImageScoreParams) => {
        mssimR: number;
        mssimG: number;
        mssimB: number;
        mssimA: number;
};

ImageScoreParams have useSimd attribute. Only when you use WASM and WASM SIMD edition, this value is used. Otherewise, ignored

export interface ImageScoreParams {
    useSimd: boolean;
}