Skip to content

Commit d032dfa

Browse files
kohakukunlgritz
authored andcommitted
fix(diff): Fix issue when computing perceptual diff (#4061)
- Fix perceptual test false positive by removing the initialization of `cr` to avoid losing the information when leaving block scope Included additional test with parameter `-fail 1`, which was giving a false positive pass for a perceptual difference. This was due to the fact that the result variable `cr` was getting out of scope for the perceptual calculation and the first `if (cr.nfail <= imagesize_t(allowfailures)) {` was testing for the result of the absolute difference instead of the perceptual difference. Before: ``` Comparing "img1.exr" and "img2.exr" PASS ``` After: ``` Comparing "img1.exr" and "img2.exr" 64 x 64, 3 channels Mean error = 0 RMS error = 0 Peak SNR = 0 Max error = 1 @ (5, 17, R) values are 0.1, 0.1, 0.1 vs 0.1, 0.6, 0.1 0 pixels (0%) over 0.008 121 pixels (2.95%) over 1 121 pixels (2.9541%) failed the perceptual test FAILURE ``` Signed-off-by: Aura Munoz <[email protected]>
1 parent 51899ea commit d032dfa

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

src/idiff/idiff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ main(int argc, char* argv[])
301301

302302
int yee_failures = 0;
303303
if (perceptual && !img0.deep()) {
304-
ImageBufAlgo::CompareResults cr;
304+
cr = {};
305305
yee_failures = ImageBufAlgo::compare_Yee(img0, img1, cr);
306306
}
307307

testsuite/diff/ref/out-fmt6.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ Computing perceptual diff of "img1.exr" vs "img1.exr"
2323
PASS
2424
Comparing "img1.exr" and "img2.exr"
2525
64 x 64, 3 channels
26-
Mean error = 0.0049235
27-
RMS error = 0.049616
28-
Peak SNR = 26.0876
29-
Max error = 0.5 @ (5, 17, G) values are 0.1, 0.1, 0.1 vs 0.1, 0.6, 0.1
30-
121 pixels (2.95%) over 0.008
26+
Mean error = 0
27+
RMS error = 0
28+
Peak SNR = 0
29+
Max error = 1 @ (5, 17, R) values are 0.1, 0.1, 0.1 vs 0.1, 0.6, 0.1
30+
0 pixels (0%) over 0.008
3131
121 pixels (2.95%) over 0.004
3232
121 pixels (2.9541%) failed the perceptual test
3333
FAILURE
3434
Comparing "img1.exr" and "img1.exr"
3535
PASS
36+
Comparing "img1.exr" and "img2.exr"
37+
64 x 64, 3 channels
38+
Mean error = 0
39+
RMS error = 0
40+
Peak SNR = 0
41+
Max error = 1 @ (5, 17, R) values are 0.1, 0.1, 0.1 vs 0.1, 0.6, 0.1
42+
0 pixels (0%) over 0.008
43+
121 pixels (2.95%) over 1.0
44+
121 pixels (2.9541%) failed the perceptual test
45+
FAILURE

testsuite/diff/ref/out.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ Computing perceptual diff of "img1.exr" vs "img1.exr"
2323
PASS
2424
Comparing "img1.exr" and "img2.exr"
2525
64 x 64, 3 channels
26-
Mean error = 0.0049235
27-
RMS error = 0.049616
28-
Peak SNR = 26.0876
29-
Max error = 0.5 @ (5, 17, G) values are 0.1, 0.1, 0.1 vs 0.1, 0.6, 0.1
30-
121 pixels (2.95%) over 0.008
26+
Mean error = 0
27+
RMS error = 0
28+
Peak SNR = 0
29+
Max error = 1 @ (5, 17, R) values are 0.1, 0.1, 0.1 vs 0.1, 0.6, 0.1
30+
0 pixels (0%) over 0.008
3131
121 pixels (2.95%) over 0.004
3232
121 pixels (2.9541%) failed the perceptual test
3333
FAILURE
3434
Comparing "img1.exr" and "img1.exr"
3535
PASS
36+
Comparing "img1.exr" and "img2.exr"
37+
64 x 64, 3 channels
38+
Mean error = 0
39+
RMS error = 0
40+
Peak SNR = 0
41+
Max error = 1 @ (5, 17, R) values are 0.1, 0.1, 0.1 vs 0.1, 0.6, 0.1
42+
0 pixels (0%) over 0.008
43+
121 pixels (2.95%) over 1
44+
121 pixels (2.9541%) failed the perceptual test
45+
FAILURE

testsuite/diff/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
command += oiiotool("-pdiff img1.exr img1.exr")
2020
command += diff_command("img1.exr", "img2.exr", extraargs="-p")
2121
command += diff_command("img1.exr", "img1.exr", extraargs="-p")
22+
command += diff_command("img1.exr", "img2.exr", extraargs="-p -fail 1")
2223

2324

2425
# Outputs to check against references

0 commit comments

Comments
 (0)