5.0.2 • Published 2 months ago

@itk-wasm/compare-images v5.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

@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>
ParameterTypeDescription
testImageImageThe input test image

CompareImagesOptions interface:

PropertyTypeDescription
baselineImagesImage[]Baseline images compare against
differenceThresholdnumberIntensity difference for pixels to be considered different.
radiusTolerancenumberRadius of the neighborhood around a pixel to search for similar intensity values.
numberOfPixelsTolerancenumberNumber of pixels that can be different before the test fails.
ignoreBoundaryPixelsbooleanIgnore boundary pixels. Useful when resampling may have introduced difference pixel values along the image edge.
webWorkernull or Worker or booleanWebWorker 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.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

CompareImagesResult interface:

PropertyTypeDescription
metricsJsonCompatibleMetrics for the baseline with the fewest number of pixels outside the tolerances.
differenceImageImageAbsolute difference image
differenceUchar2dImageImageUnsigned char, 2D difference image for rendering
webWorkerWorkerWebWorker 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>
ParameterTypeDescription
testImageImageThe input test image

CompareImagesNodeOptions interface:

PropertyTypeDescription
baselineImagesImage[]Baseline images compare against
differenceThresholdnumberIntensity difference for pixels to be considered different.
radiusTolerancenumberRadius of the neighborhood around a pixel to search for similar intensity values.
numberOfPixelsTolerancenumberNumber of pixels that can be different before the test fails.
ignoreBoundaryPixelsbooleanIgnore boundary pixels. Useful when resampling may have introduced difference pixel values along the image edge.

CompareImagesNodeResult interface:

PropertyTypeDescription
metricsJsonCompatibleMetrics for the baseline with the fewest number of pixels outside the tolerances.
differenceImageImageAbsolute difference image
differenceUchar2dImageImageUnsigned char, 2D difference image for rendering
5.0.2

2 months ago

5.0.1

4 months ago

5.0.0

4 months ago

4.0.2

5 months ago

4.0.1

5 months ago

4.0.0

6 months ago

3.0.1

7 months ago

3.0.0

7 months ago

1.0.1

9 months ago

1.0.0

9 months ago