How to use image-ssim - 2 common examples

To help you get started, we’ve selected a few image-ssim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paulirish / speedline / core / lib / speed-index.js View on Github external
function calculateFrameSimilarity(frame, target) {
	const defaultImageConfig = {
		// image-ssim uses this to interpret the arraybuffer NOT the desired channels to consider
		// jpeg-js encodes each pixel with an alpha channel set to 0xFF, so 4 channel interpretation is required
		channels: 4
	};

	const frameData = Object.assign(frame.getParsedImage(), defaultImageConfig);
	const targetData = Object.assign(target.getParsedImage(), defaultImageConfig);

	const diff = imageSSIM.compare(frameData, targetData);
	return diff.ssim;
}
github last-hit-aab / last-hit / replayer / lib / replayer / ssim.ts View on Github external
loadImage(baselineFilename, replayFilename, (images: ssim.IImage[]): void => {
			const baseline = images[0];
			const replay = images[1];
			if (isSameSize(baseline, replay)) {
				const res = ssim.compare(baseline, replay);
				resolve(res);
			} else {
				resolve({ ssim: 0.1, mcs: 0.1 });
			}
		});
	});

image-ssim

Image structural similarity (SSIM). In TypeScript/JavaScript. For browser/server.

MIT
Latest version published 9 years ago

Package Health Score

65 / 100
Full package analysis

Popular image-ssim functions