summaryrefslogtreecommitdiff
path: root/test/pdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-12-14 00:38:39 -0800
committerCarl Worth <cworth@cworth.org>2006-12-14 07:58:00 -0800
commit4438fb6dca1b4b6c0a30d66508339c3997ee94a4 (patch)
tree06d986ff2f999ba1718cdb440190187c200c9ca2 /test/pdiff
parentc7379fcea478fbd3fc5e09a10828586e641e2375 (diff)
pdiff: Move function that depends on command-line argument class to same file as main
Diffstat (limited to 'test/pdiff')
-rw-r--r--test/pdiff/Metric.cpp61
-rw-r--r--test/pdiff/Metric.h9
-rw-r--r--test/pdiff/PerceptualDiff.cpp54
-rw-r--r--test/pdiff/RGBAImage.h2
4 files changed, 62 insertions, 64 deletions
diff --git a/test/pdiff/Metric.cpp b/test/pdiff/Metric.cpp
index 5bb90ce5..c1a8b997 100644
--- a/test/pdiff/Metric.cpp
+++ b/test/pdiff/Metric.cpp
@@ -125,67 +125,6 @@ void XYZToLAB(float x, float y, float z, float &L, float &A, float &B)
B = 200.0f * (f[1] - f[2]);
}
-int Yee_Compare_Images(RGBAImage *image_a,
- RGBAImage *image_b,
- float gamma,
- float luminance,
- float field_of_view,
- bool verbose);
-
-bool Yee_Compare(CompareArgs &args)
-{
- if ((args.ImgA->Get_Width() != args.ImgB->Get_Width()) ||
- (args.ImgA->Get_Height() != args.ImgB->Get_Height())) {
- args.ErrorStr = "Image dimensions do not match\n";
- return false;
- }
-
- unsigned int i, dim, pixels_failed;
- dim = args.ImgA->Get_Width() * args.ImgA->Get_Height();
- bool identical = true;
- for (i = 0; i < dim; i++) {
- if (args.ImgA->Get(i) != args.ImgB->Get(i)) {
- identical = false;
- break;
- }
- }
- if (identical) {
- args.ErrorStr = "Images are binary identical\n";
- return true;
- }
-
- pixels_failed = Yee_Compare_Images (args.ImgA, args.ImgB,
- args.Gamma, args.Luminance,
- args.FieldOfView, args.Verbose);
-
- if (pixels_failed < args.ThresholdPixels) {
- args.ErrorStr = "Images are perceptually indistinguishable\n";
- return true;
- }
-
- char different[100];
- sprintf(different, "%d pixels are different\n", pixels_failed);
-
- args.ErrorStr = "Images are visibly different\n";
- args.ErrorStr += different;
-
- if (args.ImgDiff) {
-#if IMAGE_DIFF_CODE_ENABLED
- if (args.ImgDiff->WritePPM()) {
- args.ErrorStr += "Wrote difference image to ";
- args.ErrorStr+= args.ImgDiff->Get_Name();
- args.ErrorStr += "\n";
- } else {
- args.ErrorStr += "Could not write difference image to ";
- args.ErrorStr+= args.ImgDiff->Get_Name();
- args.ErrorStr += "\n";
- }
-#endif
- args.ErrorStr += "Generation of image \"difference\" is currently disabled\n";
- }
- return false;
-}
-
int
pdiff_compare (cairo_surface_t *surface_a,
cairo_surface_t *surface_b,
diff --git a/test/pdiff/Metric.h b/test/pdiff/Metric.h
index 4801f86b..8235a0e6 100644
--- a/test/pdiff/Metric.h
+++ b/test/pdiff/Metric.h
@@ -17,11 +17,16 @@ if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
#ifndef _METRIC_H
#define _METRIC_H
-class CompareArgs;
+#include "RGBAImage.h"
/* Image comparison metric using Yee's method
* References: A Perceptual Metric for Production Testing, Hector Yee, Journal of Graphics Tools 2004
*/
-bool Yee_Compare(CompareArgs &args);
+int Yee_Compare_Images(RGBAImage *image_a,
+ RGBAImage *image_b,
+ float gamma,
+ float luminance,
+ float field_of_view,
+ bool verbose);
#endif
diff --git a/test/pdiff/PerceptualDiff.cpp b/test/pdiff/PerceptualDiff.cpp
index 7f2229dc..6e098ed9 100644
--- a/test/pdiff/PerceptualDiff.cpp
+++ b/test/pdiff/PerceptualDiff.cpp
@@ -25,6 +25,60 @@
#include "CompareArgs.h"
#include "Metric.h"
+static bool Yee_Compare(CompareArgs &args)
+{
+ if ((args.ImgA->Get_Width() != args.ImgB->Get_Width()) ||
+ (args.ImgA->Get_Height() != args.ImgB->Get_Height())) {
+ args.ErrorStr = "Image dimensions do not match\n";
+ return false;
+ }
+
+ unsigned int i, dim, pixels_failed;
+ dim = args.ImgA->Get_Width() * args.ImgA->Get_Height();
+ bool identical = true;
+ for (i = 0; i < dim; i++) {
+ if (args.ImgA->Get(i) != args.ImgB->Get(i)) {
+ identical = false;
+ break;
+ }
+ }
+ if (identical) {
+ args.ErrorStr = "Images are binary identical\n";
+ return true;
+ }
+
+ pixels_failed = Yee_Compare_Images (args.ImgA, args.ImgB,
+ args.Gamma, args.Luminance,
+ args.FieldOfView, args.Verbose);
+
+ if (pixels_failed < args.ThresholdPixels) {
+ args.ErrorStr = "Images are perceptually indistinguishable\n";
+ return true;
+ }
+
+ char different[100];
+ sprintf(different, "%d pixels are different\n", pixels_failed);
+
+ args.ErrorStr = "Images are visibly different\n";
+ args.ErrorStr += different;
+
+ if (args.ImgDiff) {
+#if IMAGE_DIFF_CODE_ENABLED
+ if (args.ImgDiff->WritePPM()) {
+ args.ErrorStr += "Wrote difference image to ";
+ args.ErrorStr+= args.ImgDiff->Get_Name();
+ args.ErrorStr += "\n";
+ } else {
+ args.ErrorStr += "Could not write difference image to ";
+ args.ErrorStr+= args.ImgDiff->Get_Name();
+ args.ErrorStr += "\n";
+ }
+#endif
+ args.ErrorStr += "Generation of image \"difference\" is currently disabled\n";
+ }
+ return false;
+}
+
int main(int argc, char **argv)
{
CompareArgs args;
diff --git a/test/pdiff/RGBAImage.h b/test/pdiff/RGBAImage.h
index ec33d227..710cabeb 100644
--- a/test/pdiff/RGBAImage.h
+++ b/test/pdiff/RGBAImage.h
@@ -14,7 +14,7 @@
if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _RGAIMAGE_H
+#ifndef _RGBAIMAGE_H
#define _RGBAIMAGE_H
#include<string>