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
@ -86,8 +86,6 @@ export function compare(actual: Buffer, expected: Buffer, diff: Buffer|null, wid
|
|||||||
continue;
|
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) {
|
if (!fastR || !fastG || !fastB) {
|
||||||
fastR = new FastStats(r1, r2);
|
fastR = new FastStats(r1, r2);
|
||||||
fastG = new FastStats(g1, g2);
|
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 [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 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);
|
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);
|
drawRedPixel(x, y);
|
||||||
++diffCount;
|
++diffCount;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -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
|
||||||
|
After Width: | Height: | Size: 137 B |
|
After Width: | Height: | Size: 139 B |
|
After Width: | Height: | Size: 137 B |
|
After Width: | Height: | Size: 139 B |
|
After Width: | Height: | Size: 211 B |
|
After Width: | Height: | Size: 286 B |
|
After Width: | Height: | Size: 137 B |
|
After Width: | Height: | Size: 140 B |
@ -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
|
||||||
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 691 B |
|
After Width: | Height: | Size: 689 B |
|
After Width: | Height: | Size: 705 B |
|
After Width: | Height: | Size: 659 B |