@itk-wasm/compare-images
TypeScript icon, indicating that this package has built-in type declarations

5.1.1 • Public • Published

@itk-wasm/compare-images

npm version

Compare images with a tolerance for regression testing.

👨‍💻 Live API Demo

🕮 Documentation 📚

Installation

npm install @itk-wasm/compare-images

Usage

Browser interface

Import:

import {
  compareImages,
  setPipelinesBaseUrl,
  getPipelinesBaseUrl,
} from "@itk-wasm/compare-images"

compareImages

Compare images with a tolerance for regression testing.

async function compareImages(
  testImage: Image,
  options: CompareImagesOptions = { baselineImages: [] as Image[], }
) : Promise<CompareImagesResult>
Parameter Type Description
testImage Image The input test image

CompareImagesOptions interface:

Property Type Description
baselineImages Image[] Baseline images compare against
differenceThreshold number Intensity difference for pixels to be considered different.
radiusTolerance number Radius of the neighborhood around a pixel to search for similar intensity values.
numberOfPixelsTolerance number Number of pixels that can be different before the test fails.
ignoreBoundaryPixels boolean Ignore boundary pixels. Useful when resampling may have introduced difference pixel values along the image edge.
webWorker null or Worker or boolean WebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to false to run in the current thread / worker.
noCopy boolean When SharedArrayBuffer's are not available, do not copy inputs.

CompareImagesResult interface:

Property Type Description
metrics JsonCompatible Metrics for the baseline with the fewest number of pixels outside the tolerances.
differenceImage Image Absolute difference image
differenceUchar2dImage Image Unsigned char, 2D difference image for rendering
webWorker Worker WebWorker used for computation.

setPipelinesBaseUrl

Set base URL for WebAssembly assets when vendored.

function setPipelinesBaseUrl(
  baseUrl: string | URL
) : void

getPipelinesBaseUrl

Get base URL for WebAssembly assets when vendored.

function getPipelinesBaseUrl() : string | URL

Node interface

Import:

import {
  compareImagesNode,
} from "@itk-wasm/compare-images"

compareImagesNode

Compare images with a tolerance for regression testing.

async function compareImagesNode(
  testImage: Image,
  options: CompareImagesOptions = { baselineImages: [] as Image[], }
) : Promise<CompareImagesNodeResult>
Parameter Type Description
testImage Image The input test image

CompareImagesNodeOptions interface:

Property Type Description
baselineImages Image[] Baseline images compare against
differenceThreshold number Intensity difference for pixels to be considered different.
radiusTolerance number Radius of the neighborhood around a pixel to search for similar intensity values.
numberOfPixelsTolerance number Number of pixels that can be different before the test fails.
ignoreBoundaryPixels boolean Ignore boundary pixels. Useful when resampling may have introduced difference pixel values along the image edge.

CompareImagesNodeResult interface:

Property Type Description
metrics JsonCompatible Metrics for the baseline with the fewest number of pixels outside the tolerances.
differenceImage Image Absolute difference image
differenceUchar2dImage Image Unsigned char, 2D difference image for rendering

Package Sidebar

Install

npm i @itk-wasm/compare-images

Weekly Downloads

3

Version

5.1.1

License

Apache-2.0

Unpacked Size

2.93 MB

Total Files

118

Last publish

Collaborators

  • paulhax
  • thewtex