From 0842e09570cfa8107cdbbd65eaaa383248d8f651 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 30 Nov 2017 13:59:02 -0800 Subject: [PATCH] Debugging the image comparison. --- tools/auto-tester/src/ImageComparer.cpp | 35 +++++++++++----------- tools/auto-tester/src/Test.cpp | 2 +- tools/auto-tester/src/ui/MismatchWindow.ui | 6 ++-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/tools/auto-tester/src/ImageComparer.cpp b/tools/auto-tester/src/ImageComparer.cpp index 9151255d96..12ef20010c 100644 --- a/tools/auto-tester/src/ImageComparer.cpp +++ b/tools/auto-tester/src/ImageComparer.cpp @@ -26,9 +26,9 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co const double c2 = (K2 * L) * (K2 * L); // Coefficients for luminosity calculation - const double RED_COEFFICIENT = 0.212655; - const double GREEN_COEFFICIENT = 0.715158; - const double BLUE_COEFFICIENT = 0.072187; + const double R_Y = 0.212655f; + const double G_Y = 0.715158f; + const double B_Y = 0.072187f; // First go over all full 8x8 blocks // This is done in 3 loops @@ -42,7 +42,11 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co const int WIN_SIZE = 8; int x{ 0 }; // column index (start of block) int y{ 0 }; // row index (start of block - double ssimMax{ 0.0 }; + double ssimMin{ 1.0 }; + + // Pixels are processed in sqare blocks + double p[WIN_SIZE * WIN_SIZE]; + double q[WIN_SIZE * WIN_SIZE]; while (x < expectedImage.width()) { int lastX = x + WIN_SIZE; @@ -56,22 +60,17 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co y -= (lastY - expectedImage.height()); } - // Collect pixels + // Collect pixels into linear arrays int i{ 0 }; - double p[WIN_SIZE * WIN_SIZE]; - double q[WIN_SIZE * WIN_SIZE]; for (int xx = 0; xx < WIN_SIZE; ++xx) { for (int yy = 0; yy < WIN_SIZE; ++yy) { // Get pixels - QRgb pixelP = expectedImage.pixel(QPoint(xx, yy)); - QRgb pixelQ = resultImage.pixel(QPoint(xx, yy)); + QRgb pixelP = expectedImage.pixel(QPoint(x + xx, y + yy)); + QRgb pixelQ = resultImage.pixel(QPoint(x + xx, y + yy)); - // Convert to vec3 - p[i] = - RED_COEFFICIENT * qRed(pixelP) + GREEN_COEFFICIENT * qGreen(pixelP) + BLUE_COEFFICIENT * qBlue(pixelP); - - q[i] = - RED_COEFFICIENT * qRed(pixelQ) + GREEN_COEFFICIENT * qGreen(pixelQ) + BLUE_COEFFICIENT * qBlue(pixelQ); + // Convert to luminence + p[i] = R_Y * qRed(pixelP) + G_Y * qGreen(pixelP) + B_Y * qBlue(pixelP); + q[i] = R_Y * qRed(pixelQ) + G_Y * qGreen(pixelQ) + B_Y * qBlue(pixelQ); ++i; } @@ -106,8 +105,8 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co double ssim = numerator / denominator; - if (ssim > ssimMax) { - ssimMax = ssim; + if (ssim < ssimMin) { + ssimMin = ssim; } y += WIN_SIZE; @@ -115,5 +114,5 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co x += WIN_SIZE; } - return ssimMax; + return ssimMin; }; diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index ae5fd33dd5..5515c0b8dd 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -24,7 +24,7 @@ Test::Test() { bool Test::compareImageLists(QStringList expectedImages, QStringList resultImages) { // Loop over both lists and compare each pair of images // Quit loop if user has aborted due to a failed test. - const double THRESHOLD{ 0.99999 }; + const double THRESHOLD{ 0.98 }; bool success{ true }; bool keepOn{ true }; for (int i = 0; keepOn && i < expectedImages.length(); ++i) { diff --git a/tools/auto-tester/src/ui/MismatchWindow.ui b/tools/auto-tester/src/ui/MismatchWindow.ui index ab3a8d57c8..cab6c61e1c 100644 --- a/tools/auto-tester/src/ui/MismatchWindow.ui +++ b/tools/auto-tester/src/ui/MismatchWindow.ui @@ -135,9 +135,9 @@ - 960 + 810 600 - 181 + 720 28 @@ -147,7 +147,7 @@ - error + similarity