Skip to content

Commit

Permalink
fix(ssim-cie94): make sure a single off pixel yields diff in comparat…
Browse files Browse the repository at this point in the history
…or (microsoft#24348)

This patch brings in antialiasing tests from `looks-same` project for
our experimental `ssim-cie94` comparator.

One of the new tests found a bug in our implementation.

References microsoft#24312
  • Loading branch information
aslushnikov authored and Germandrummer92 committed Oct 27, 2023
1 parent bceb1cc commit 023963f
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/playwright-core/src/image_tools/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ export function compare(actual: Buffer, expected: Buffer, diff: Buffer|null, wid
continue;
}

// if this pixel is a part of a flood fill of a 3x3 square then it cannot be
// anti-aliasing pixel so it must be a pixel difference.
if (!fastR || !fastG || !fastB) {
fastR = new FastStats(r1, r2);
fastG = new FastStats(g1, g2);
Expand All @@ -97,7 +95,9 @@ export function compare(actual: Buffer, expected: Buffer, diff: Buffer|null, wid
const [varX2, varY2] = r1.boundXY(x + VARIANCE_WINDOW_RADIUS, y + VARIANCE_WINDOW_RADIUS);
const var1 = fastR.varianceC1(varX1, varY1, varX2, varY2) + fastG.varianceC1(varX1, varY1, varX2, varY2) + fastB.varianceC1(varX1, varY1, varX2, varY2);
const var2 = fastR.varianceC2(varX1, varY1, varX2, varY2) + fastG.varianceC2(varX1, varY1, varX2, varY2) + fastB.varianceC2(varX1, varY1, varX2, varY2);
if (var1 === 0 && var2 === 0) {
// if this pixel is a part of a flood fill of a 3x3 square of either of the images, then it cannot be
// anti-aliasing pixel so it must be a pixel difference.
if (var1 === 0 || var2 === 0) {
drawRedPixel(x, y);
++diffCount;
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
These tests are coming from the `looks-same` library:
- https://github.com/gemini-testing/looks-same/blob/b9399bce8fd980e6e59cf740bee3cd3fe66c3eae/test/test.js
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
These tests are coming from the `looks-same` library:
- https://github.com/gemini-testing/looks-same/blob/b9399bce8fd980e6e59cf740bee3cd3fe66c3eae/test/test.js
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 023963f

Please sign in to comment.