Skip to content

Commit

Permalink
Added threshold to diff images in Testbed.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Aug 1, 2023
1 parent 4f6a4e8 commit 38cb8b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions tests/Testbed/TestbedContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,9 @@ static ColorRGBub GetHeatMapColor(int diff, int scale = 1)
return ColorRGBub{ heapMapLUT[diff][0], heapMapLUT[diff][1], heapMapLUT[diff][2] };
}

int TestbedContext::DiffImagesTGA(const std::string& name, int diffScale)
int TestbedContext::DiffImagesTGA(const std::string& name, int threshold, int scale)
{
/* Load input images and validate they have the same dimensions */
// Load input images and validate they have the same dimensions
std::vector<ColorRGBub> pixelsA, pixelsB, pixelsDiff;
Extent2D extentA, extentB;

Expand All @@ -905,7 +905,7 @@ int TestbedContext::DiffImagesTGA(const std::string& name, int diffScale)
if (extentA != extentB)
return -3;

/* Generate heat-map image */
// Generate heat-map image
int highestDiff = 0;
pixelsDiff.resize(extentA.width * extentA.height);

Expand All @@ -920,18 +920,19 @@ int TestbedContext::DiffImagesTGA(const std::string& name, int diffScale)
GetColorDiff(colorA.b, colorB.b),
};
int maxDiff = std::max({ diff[0], diff[1], diff[2] });
pixelsDiff[i] = GetHeatMapColor(maxDiff, diffScale);
pixelsDiff[i] = GetHeatMapColor(maxDiff, scale);
highestDiff = std::max(highestDiff, maxDiff);
}

if (highestDiff != 0)
if (highestDiff > threshold)
{
// Save diff inage and return highest difference value
if (!SaveImageTGA(pixelsDiff, extentA, diffPath + name + ".Diff.tga", verbose))
return -4;
return highestDiff;
}

/* Return highest difference value */
return highestDiff;
return 0;
}


Expand Down
2 changes: 1 addition & 1 deletion tests/Testbed/TestbedContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class TestbedContext
void SaveDepthImageTGA(const std::vector<float>& image, const LLGL::Extent2D& extent, const std::string& name, float nearPlane, float farPlane);

// Creates a heat-map image from the two input filenames and returns the highest difference pixel value. A negative value indicates an error.
int DiffImagesTGA(const std::string& name, int diffScale = 1);
int DiffImagesTGA(const std::string& name, int threshold = 1, int scale = 1);

};

Expand Down

0 comments on commit 38cb8b8

Please sign in to comment.