Read test: added perceptive fuzziness

Added a new parameter to the read tests called `perceptive-fuzz`.
The parameter, when active, modifies the fuzziness value based on the alpha value of the pixel. The more transparent the pixel, the more the fuzziness value increases.

We have found that some image manipulation functions give different results depending on the architecture (we think it is differences in rounding). These differences can become problematic with small alpha values ​​when there are several image conversions from normal alpha to premultiplied alpha (and vice versa).
In particular, the offending plugin is XCF.

The parameter should be set if and only if necessary. CMakeList has not been modified to allow it to be enabled on all format images (you can still try it from the command line). To use it, you need to set it in the JSON file of the image that has problems (after careful analysis).

More info about the issue on #18 

This MR also fixes a bug in `fazzeq()`: it only compared 1/4 of the image.

Below is the same XCF image rendered on AMD64 and PowerPC:

- AMD64:

![image](/uploads/7815ee49fac9b06d08bf1e0e3879f16e/image.png)

- PowerPC:

![image](/uploads/d7432902d638f6caf9589ebb4ad99827/image.png)

The image is visually the same because the differences are with very low alpha and therefore are negligible. The patch proposed with this MR is useful in these cases.
This commit is contained in:
Mirco Miranda
2025-01-24 13:07:32 +00:00
committed by Albert Astals Cid
parent 424e7a75de
commit 49060026b7
10 changed files with 110 additions and 13 deletions

View File

@ -210,9 +210,11 @@ int main(int argc, char **argv)
QStringLiteral("max"));
QCommandLineOption skipOptTest({QStringLiteral("skip-optional-tests")},
QStringLiteral("Skip optional data tests (metadata, resolution, etc.)."));
QCommandLineOption perceptiveFuzz({QStringLiteral("perceptive-fuzz")}, QStringLiteral("The fuzziness value is scaled based on the alpha channel value."));
parser.addOption(fuzz);
parser.addOption(skipOptTest);
parser.addOption(perceptiveFuzz);
parser.process(app);
const QStringList args = parser.positionalArguments();
@ -378,11 +380,16 @@ int main(int argc, char **argv)
expImage = expImage.convertToFormat(cmpFormat);
}
auto tmpFuzziness = fuzziness;
auto isFuzzPerceptive = parser.isSet(perceptiveFuzz);
if (tmpFuzziness == 0) {
// If the fuzziness value is not explicitly set I use the one set for the current image.
tmpFuzziness = timg.fuzziness();
}
if (fuzzyeq(inputImage, expImage, tmpFuzziness)) {
if (!isFuzzPerceptive) {
// If the perceptiveFuzziness value is not explicitly set I use the one set for the current image.
isFuzzPerceptive = timg.perceptiveFuzziness();
}
if (fuzzyeq(inputImage, expImage, tmpFuzziness, isFuzzPerceptive)) {
QTextStream(stdout) << "PASS : " << fi.fileName() << "\n";
++passed;
} else {