Updated AutoTester.

This commit is contained in:
NissimHadar 2018-05-25 17:37:31 -07:00
parent 20d2128a10
commit ddea1c64bc
3 changed files with 10 additions and 4 deletions

View file

@ -15,6 +15,12 @@
// Computes SSIM - see https://en.wikipedia.org/wiki/Structural_similarity
// The value is computed for the luminance component and the average value is returned
double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) const {
// Make sure the image is 8 bits per colour
QImage::Format format = expectedImage.format();
if (format != QImage::Format::Format_ARGB32) {
throw -1;
}
const int L = 255; // (2^number of bits per pixel) - 1
const double K1 { 0.01 };
const double K2 { 0.03 };
@ -54,8 +60,8 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co
// Collect pixels into linear arrays
int i{ 0 };
for (int xx = 0; xx < WIN_SIZE; ++xx) {
for (int yy = 0; yy < WIN_SIZE; ++yy) {
for (int xx = 0; xx < WIN_SIZE && x + xx < expectedImage.width(); ++xx) {
for (int yy = 0; yy < WIN_SIZE && y + yy < expectedImage.height(); ++yy) {
// Get pixels
QRgb pixelP = expectedImage.pixel(QPoint(x + xx, y + yy));
QRgb pixelQ = resultImage.pixel(QPoint(x + xx, y + yy));

View file

@ -63,7 +63,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar)
// 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.99 };
const double THRESHOLD { 0.9995 };
bool success{ true };
bool keepOn{ true };
for (int i = 0; keepOn && i < expectedImagesFullFilenames.length(); ++i) {

View file

@ -129,7 +129,7 @@ void AutoTester::saveImage(int index) {
pixmap.loadFromData(downloaders[index]->downloadedData());
QImage image = pixmap.toImage();
image = image.convertToFormat(QImage::Format_RGB32);
image = image.convertToFormat(QImage::Format_ARGB32);
QString fullPathname = _directoryName + "/" + _filenames[index];
if (!image.save(fullPathname, 0, 100)) {