mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Debugging the image comparison.
This commit is contained in:
parent
2e8fe40da8
commit
0842e09570
3 changed files with 21 additions and 22 deletions
|
@ -26,9 +26,9 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co
|
||||||
const double c2 = (K2 * L) * (K2 * L);
|
const double c2 = (K2 * L) * (K2 * L);
|
||||||
|
|
||||||
// Coefficients for luminosity calculation
|
// Coefficients for luminosity calculation
|
||||||
const double RED_COEFFICIENT = 0.212655;
|
const double R_Y = 0.212655f;
|
||||||
const double GREEN_COEFFICIENT = 0.715158;
|
const double G_Y = 0.715158f;
|
||||||
const double BLUE_COEFFICIENT = 0.072187;
|
const double B_Y = 0.072187f;
|
||||||
|
|
||||||
// First go over all full 8x8 blocks
|
// First go over all full 8x8 blocks
|
||||||
// This is done in 3 loops
|
// This is done in 3 loops
|
||||||
|
@ -42,7 +42,11 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co
|
||||||
const int WIN_SIZE = 8;
|
const int WIN_SIZE = 8;
|
||||||
int x{ 0 }; // column index (start of block)
|
int x{ 0 }; // column index (start of block)
|
||||||
int y{ 0 }; // row 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()) {
|
while (x < expectedImage.width()) {
|
||||||
int lastX = x + WIN_SIZE;
|
int lastX = x + WIN_SIZE;
|
||||||
|
@ -56,22 +60,17 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co
|
||||||
y -= (lastY - expectedImage.height());
|
y -= (lastY - expectedImage.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect pixels
|
// Collect pixels into linear arrays
|
||||||
int i{ 0 };
|
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 xx = 0; xx < WIN_SIZE; ++xx) {
|
||||||
for (int yy = 0; yy < WIN_SIZE; ++yy) {
|
for (int yy = 0; yy < WIN_SIZE; ++yy) {
|
||||||
// Get pixels
|
// Get pixels
|
||||||
QRgb pixelP = expectedImage.pixel(QPoint(xx, yy));
|
QRgb pixelP = expectedImage.pixel(QPoint(x + xx, y + yy));
|
||||||
QRgb pixelQ = resultImage.pixel(QPoint(xx, yy));
|
QRgb pixelQ = resultImage.pixel(QPoint(x + xx, y + yy));
|
||||||
|
|
||||||
// Convert to vec3
|
// Convert to luminence
|
||||||
p[i] =
|
p[i] = R_Y * qRed(pixelP) + G_Y * qGreen(pixelP) + B_Y * qBlue(pixelP);
|
||||||
RED_COEFFICIENT * qRed(pixelP) + GREEN_COEFFICIENT * qGreen(pixelP) + BLUE_COEFFICIENT * qBlue(pixelP);
|
q[i] = R_Y * qRed(pixelQ) + G_Y * qGreen(pixelQ) + B_Y * qBlue(pixelQ);
|
||||||
|
|
||||||
q[i] =
|
|
||||||
RED_COEFFICIENT * qRed(pixelQ) + GREEN_COEFFICIENT * qGreen(pixelQ) + BLUE_COEFFICIENT * qBlue(pixelQ);
|
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -106,8 +105,8 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co
|
||||||
|
|
||||||
double ssim = numerator / denominator;
|
double ssim = numerator / denominator;
|
||||||
|
|
||||||
if (ssim > ssimMax) {
|
if (ssim < ssimMin) {
|
||||||
ssimMax = ssim;
|
ssimMin = ssim;
|
||||||
}
|
}
|
||||||
|
|
||||||
y += WIN_SIZE;
|
y += WIN_SIZE;
|
||||||
|
@ -115,5 +114,5 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co
|
||||||
x += WIN_SIZE;
|
x += WIN_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ssimMax;
|
return ssimMin;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ Test::Test() {
|
||||||
bool Test::compareImageLists(QStringList expectedImages, QStringList resultImages) {
|
bool Test::compareImageLists(QStringList expectedImages, QStringList resultImages) {
|
||||||
// Loop over both lists and compare each pair of images
|
// Loop over both lists and compare each pair of images
|
||||||
// Quit loop if user has aborted due to a failed test.
|
// 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 success{ true };
|
||||||
bool keepOn{ true };
|
bool keepOn{ true };
|
||||||
for (int i = 0; keepOn && i < expectedImages.length(); ++i) {
|
for (int i = 0; keepOn && i < expectedImages.length(); ++i) {
|
||||||
|
|
|
@ -135,9 +135,9 @@
|
||||||
<widget class="QLabel" name="errorLabel">
|
<widget class="QLabel" name="errorLabel">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>960</x>
|
<x>810</x>
|
||||||
<y>600</y>
|
<y>600</y>
|
||||||
<width>181</width>
|
<width>720</width>
|
||||||
<height>28</height>
|
<height>28</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>error</string>
|
<string>similarity</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Reference in a new issue