Skip to content

Commit

Permalink
feat(compare-images): define CompareImagesMetric
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Aug 21, 2023
1 parent 08ed5bc commit 5accc83
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Generated file. To retain edits, remove this comment.
import CompareImagesMetric from './compare-images-metric.js'

import { Image } from 'itk-wasm'

interface CompareDoubleImagesNodeResult {
/** Metrics for the baseline with the fewest number of pixels outside the tolerances. */
metrics: any
metrics: CompareImagesMetric

/** Absolute difference image */
differenceImage: Image
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Generated file. To retain edits, remove this comment.

import {
Image,
JsonObject,
Expand All @@ -11,7 +9,7 @@ import {

import CompareDoubleImagesOptions from './compare-double-images-options.js'
import CompareDoubleImagesNodeResult from './compare-double-images-node-result.js'

import CompareImagesMetric from './compare-images-metric.js'

import path from 'path'

Expand Down Expand Up @@ -96,7 +94,7 @@ async function compareDoubleImagesNode(
}

const result = {
metrics: (outputs[0].data as JsonObject).data,
metrics: (outputs[0].data as JsonObject).data as CompareImagesMetric,
differenceImage: outputs[1].data as Image,
differenceUchar2dImage: outputs[2].data as Image,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated file. To retain edits, remove this comment.
import CompareImagesMetric from './compare-images-metric.js'

import { Image } from 'itk-wasm'

Expand All @@ -7,14 +7,13 @@ interface CompareDoubleImagesResult {
webWorker: Worker | null

/** Metrics for the baseline with the fewest number of pixels outside the tolerances. */
metrics: any
metrics: CompareImagesMetric

/** Absolute difference image */
differenceImage: Image

/** Unsigned char, 2D difference image for rendering */
differenceUchar2dImage: Image

}

export default CompareDoubleImagesResult
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Generated file. To retain edits, remove this comment.

import {
Image,
JsonObject,
Expand All @@ -11,6 +9,7 @@ import {

import CompareDoubleImagesOptions from './compare-double-images-options.js'
import CompareDoubleImagesResult from './compare-double-images-result.js'
import CompareImagesMetric from './compare-images-metric.js'


import { getPipelinesBaseUrl } from './pipelines-base-url.js'
Expand Down Expand Up @@ -100,7 +99,7 @@ async function compareDoubleImages(

const result = {
webWorker: usedWebWorker as Worker,
metrics: (outputs[0].data as JsonObject).data,
metrics: (outputs[0].data as JsonObject).data as CompareImagesMetric,
differenceImage: outputs[1].data as Image,
differenceUchar2dImage: outputs[2].data as Image,
}
Expand Down
21 changes: 21 additions & 0 deletions packages/compare-images/typescript/src/compare-images-metric.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
interface CompareImagesMetric {
/** Whether the test image and one of the baseline images are equal given specified tolerances. */
almostEqual: boolean;

/** The number of pixels that are different. */
numberOfPixelsDifferent: number;

/** Minimum pixel intensity difference. */
minimumDifference: number;

/** Maximum pixel intensity difference. */
maximumDifference: number;

/** Mean pixel intensity difference. */
meanDifference: number;

/** Total pixel intensity difference. */
totalDifference: number;
}

export default CompareImagesMetric
5 changes: 2 additions & 3 deletions packages/compare-images/typescript/src/index-node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated file. To retain edits, remove this comment.


import CompareImagesMetric from './compare-images-metric.js'
export type { CompareImagesMetric }

import CompareDoubleImagesNodeResult from './compare-double-images-node-result.js'
export type { CompareDoubleImagesNodeResult }
Expand Down
4 changes: 2 additions & 2 deletions packages/compare-images/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Generated file. To retain edits, remove this comment.

export * from './pipelines-base-url.js'
export * from './pipeline-worker-url.js'

import CompareImagesMetric from './compare-images-metric.js'
export type { CompareImagesMetric }

import CompareDoubleImagesResult from './compare-double-images-result.js'
export type { CompareDoubleImagesResult }
Expand Down

0 comments on commit 5accc83

Please sign in to comment.