fix(ssim-cie94): make sure a single off pixel yields diff in comparator (#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 https://github.com/microsoft/playwright/issues/24312
This commit is contained in:
Andrey Lushnikov 2023-07-21 12:27:52 -07:00 committed by GitHub
parent c40a1dd418
commit d307c8e63a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 7 additions and 3 deletions

View File

@ -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);
@ -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;

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B