3 Copyright (C) 2006 Yangli Hector Yee
5 This program is free software; you can redistribute it and/or modify it under the terms of the
6 GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
7 or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 See the GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License along with this program;
14 if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 static const char* copyright
=
23 "PerceptualDiff version 1.0, Copyright (C) 2006 Yangli Hector Yee\n\
24 PerceptualDiff comes with ABSOLUTELY NO WARRANTY;\n\
25 This is free software, and you are welcome\n\
26 to redistribute it under certain conditions;\n\
27 See the GPL page for details: http://www.gnu.org/copyleft/gpl.html\n\n";
29 static const char *usage
=
30 "PeceptualDiff image1.tif image2.tif\n\n\
31 Compares image1.tif and image2.tif using a perceptually based image metric\n\
33 \t-verbose : Turns on verbose mode\n\
34 \t-fov deg : Field of view in degrees (0.1 to 89.9)\n\
35 \t-threshold p : #pixels p below which differences are ignored\n\
36 \t-gamma g : Value to convert rgb into linear space (default 2.2)\n\
37 \t-luminance l : White luminance (default 100.0 cdm^-2)\n\
39 \n Note: Input files can also be in the PNG format\
43 args_init (args_t
*args
)
45 args
->surface_a
= NULL
;
46 args
->surface_b
= NULL
;
47 args
->Verbose
= false;
48 args
->FieldOfView
= 45.0f
;
50 args
->ThresholdPixels
= 100;
51 args
->Luminance
= 100.0f
;
55 args_fini (args_t
*args
)
57 cairo_surface_destroy (args
->surface_a
);
58 cairo_surface_destroy (args
->surface_b
);
62 args_parse (args_t
*args
, int argc
, char **argv
)
66 fprintf (stderr
, "%s", copyright
);
67 fprintf (stderr
, "%s", usage
);
70 for (i
= 0; i
< argc
; i
++) {
72 args
->surface_a
= cairo_image_surface_create_from_png (argv
[1]);
73 if (cairo_surface_status (args
->surface_a
))
75 fprintf (stderr
, "FAIL: Cannot open %s: %s\n",
76 argv
[1], cairo_status_to_string (cairo_surface_status (args
->surface_a
)));
80 args
->surface_b
= cairo_image_surface_create_from_png (argv
[2]);
81 if (cairo_surface_status (args
->surface_b
))
83 fprintf (stderr
, "FAIL: Cannot open %s: %s\n",
84 argv
[2], cairo_status_to_string (cairo_surface_status (args
->surface_b
)));
88 if (strstr(argv
[i
], "-fov")) {
90 args
->FieldOfView
= (float) atof(argv
[i
+ 1]);
92 } else if (strstr(argv
[i
], "-verbose")) {
94 } else if (strstr(argv
[i
], "-threshold")) {
96 args
->ThresholdPixels
= atoi(argv
[i
+ 1]);
98 } else if (strstr(argv
[i
], "-gamma")) {
100 args
->Gamma
= (float) atof(argv
[i
+ 1]);
102 }else if (strstr(argv
[i
], "-luminance")) {
104 args
->Luminance
= (float) atof(argv
[i
+ 1]);
113 args_print (args_t
*args
)
115 printf("Field of view is %f degrees\n", args
->FieldOfView
);
116 printf("Threshold pixels is %d pixels\n", args
->ThresholdPixels
);
117 printf("The Gamma is %f\n", args
->Gamma
);
118 printf("The Display's luminance is %f candela per meter squared\n", args
->Luminance
);