Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(12)

Delta Between Two Patch Sets: files/source/CompareArgs.cpp

Issue 89059: add ignore edge function in pdiff. SVN Base: http://o3d.googlecode.com/svn/trunk/googleclient/third_party/pdiff/
Left Patch Set: '' Created 5 months, 1 week ago
Right Patch Set: '' Created 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 Comapre Args 2 Comapre Args
3 Copyright (C) 2006 Yangli Hector Yee 3 Copyright (C) 2006 Yangli Hector Yee
4 4
5 This program is free software; you can redistribute it and/or modify it under th e terms of the 5 This program is free software; you can redistribute it and/or modify it under th e terms of the
6 GNU General Public License as published by the Free Software Foundation; either version 2 of the License, 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. 7 or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 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. 10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
(...skipping 14 matching lines...) Expand all
25 PerceptualDiff comes with ABSOLUTELY NO WARRANTY;\n\ 25 PerceptualDiff comes with ABSOLUTELY NO WARRANTY;\n\
26 This is free software, and you are welcome\n\ 26 This is free software, and you are welcome\n\
27 to redistribute it under certain conditions;\n\ 27 to redistribute it under certain conditions;\n\
28 See the GPL page for details: http://www.gnu.org/copyleft/gpl.html\n\n"; 28 See the GPL page for details: http://www.gnu.org/copyleft/gpl.html\n\n";
29 29
30 static const char *usage = 30 static const char *usage =
31 "PeceptualDiff image1.tif image2.tif\n\n\ 31 "PeceptualDiff image1.tif image2.tif\n\n\
32 Compares image1.tif and image2.tif using a perceptually based image metric\n\ 32 Compares image1.tif and image2.tif using a perceptually based image metric\n\
33 Options:\n\ 33 Options:\n\
34 \t-verbose : Turns on verbose mode\n\ 34 \t-verbose : Turns on verbose mode\n\
35 \t-noedge e : Degree of edge ignore (0.0 to 1.0), 1 is complete ignore\n\ 35 \t-ignoreEdges e : Ignore edges in comparison. e (0 to 7) is the\n\
36 \t max number of neighbors the pixel can have to\n\
37 \t be considered as edge.\n\
36 \t-fov deg : Field of view in degrees (0.1 to 89.9)\n\ 38 \t-fov deg : Field of view in degrees (0.1 to 89.9)\n\
37 \t-threshold p : #pixels p below which differences are ignored\n\ 39 \t-threshold p : #pixels p below which differences are ignored\n\
38 \t-gamma g : Value to convert rgb into linear space (default 2.2)\n\ 40 \t-gamma g : Value to convert rgb into linear space (default 2.2)\n\
39 \t-luminance l : White luminance (default 100.0 cdm^-2)\n\ 41 \t-luminance l : White luminance (default 100.0 cdm^-2)\n\
40 \t-luminanceonly : Only consider luminance; ignore chroma (color) in the compari son\n\ 42 \t-luminanceonly : Only consider luminance; ignore chroma (color) in the compari son\n\
41 \t-colorfactor : How much of color to use, 0.0 to 1.0, 0.0 = ignore color.\n\ 43 \t-colorfactor : How much of color to use, 0.0 to 1.0, 0.0 = ignore color.\n\
42 \t-downsample : How many powers of two to down sample the image.\n\ 44 \t-downsample : How many powers of two to down sample the image.\n\
43 \t-output o.ppm : Write difference to the file o.ppm\n\ 45 \t-output o.ppm : Write difference to the file o.ppm\n\
44 \n\ 46 \n\
45 \n Note: Input or Output files can also be in the PNG or JPG format or any forma t\ 47 \n Note: Input or Output files can also be in the PNG or JPG format or any forma t\
46 \n that FreeImage supports.\ 48 \n that FreeImage supports.\
47 \n"; 49 \n";
48 50
49 CompareArgs::CompareArgs() 51 CompareArgs::CompareArgs()
50 { 52 {
51 ImgA = NULL; 53 ImgA = NULL;
52 ImgB = NULL; 54 ImgB = NULL;
53 ImgDiff = NULL; 55 ImgDiff = NULL;
54 Verbose = false; 56 Verbose = false;
55 LuminanceOnly = false; 57 LuminanceOnly = false;
56 » EdgeDetectDegree = 0.0f; 58 » IgnoreEdge = false;
59 EdgeNeighborNum = 0;
57 FieldOfView = 45.0f; 60 FieldOfView = 45.0f;
58 Gamma = 2.2f; 61 Gamma = 2.2f;
59 ThresholdPixels = 100; 62 ThresholdPixels = 100;
60 Luminance = 100.0f; 63 Luminance = 100.0f;
61 ColorFactor = 1.0f; 64 ColorFactor = 1.0f;
62 DownSample = 0; 65 DownSample = 0;
63 } 66 }
64 67
65 CompareArgs::~CompareArgs() 68 CompareArgs::~CompareArgs()
66 { 69 {
67 if (ImgA) delete ImgA; 70 if (ImgA) delete ImgA;
68 if (ImgB) delete ImgB; 71 if (ImgB) delete ImgB;
69 if (ImgDiff) delete ImgDiff; 72 if (ImgDiff) delete ImgDiff;
70 } 73 }
71 74
72 bool CompareArgs::Parse_Args(int argc, char **argv) 75 bool CompareArgs::Parse_Args(int argc, char **argv)
73 { 76 {
74 if (argc < 3) { 77 if (argc < 3) {
75 ErrorStr = copyright; 78 ErrorStr = copyright;
76 ErrorStr += usage; 79 ErrorStr += usage;
77 return false; 80 return false;
78 } 81 }
79 int image_count = 0; 82 int image_count = 0;
80 const char* output_file_name = NULL; 83 const char* output_file_name = NULL;
81 for (int i = 1; i < argc; i++) { 84 for (int i = 1; i < argc; i++) {
82 if (strcmp(argv[i], "-fov") == 0) { 85 if (strcmp(argv[i], "-fov") == 0) {
83 if (++i < argc) { 86 if (++i < argc) {
84 FieldOfView = (float) atof(argv[i]); 87 FieldOfView = (float) atof(argv[i]);
85 } 88 }
86 » » } else if (strcmp(argv[i], "-noedge") == 0) { 89 » » } else if (strcmp(argv[i], "-ignoreEdges") == 0) {
87 if (++i < argc) { 90 if (++i < argc) {
88 » » » » EdgeDetectDegree = (float) atof(argv[i]); 91 IgnoreEdge = true;
89 » » » » if (EdgeDetectDegree < 0.0f) 92 » » » » EdgeNeighborNum = (float) atoi(argv[i]);
90 » » » » » EdgeDetectDegree = 0.0f; 93 » » » » if (EdgeNeighborNum < 0)
91 » » » » if (EdgeDetectDegree > 1.0f) 94 » » » » » EdgeNeighborNum = 0;
92 » » » » » EdgeDetectDegree = 1.0f; 95 » » » » if (EdgeNeighborNum > 7)
96 » » » » » EdgeNeighborNum = 7;
93 } 97 }
94 } else if (strcmp(argv[i], "-verbose") == 0) { 98 } else if (strcmp(argv[i], "-verbose") == 0) {
95 Verbose = true; 99 Verbose = true;
96 } else if (strcmp(argv[i], "-threshold") == 0) { 100 } else if (strcmp(argv[i], "-threshold") == 0) {
97 if (++i < argc) { 101 if (++i < argc) {
98 ThresholdPixels = atoi(argv[i]); 102 ThresholdPixels = atoi(argv[i]);
99 } 103 }
100 } else if (strcmp(argv[i], "-gamma") == 0) { 104 } else if (strcmp(argv[i], "-gamma") == 0) {
101 if (++i < argc) { 105 if (++i < argc) {
102 Gamma = (float) atof(argv[i]); 106 Gamma = (float) atof(argv[i]);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ImgA = tmp; 153 ImgA = tmp;
150 } 154 }
151 tmp = ImgB->DownSample(); 155 tmp = ImgB->DownSample();
152 if (tmp) { 156 if (tmp) {
153 delete ImgB; 157 delete ImgB;
154 ImgB = tmp; 158 ImgB = tmp;
155 } 159 }
156 } 160 }
157 161
158 if(output_file_name) { 162 if(output_file_name) {
159 ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height(), output_fi le_name); 163 ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height(),
164 output_file_name);
160 } 165 }
161 // if no output_file_name is specified, and edge detection is enabled. 166 // if no output_file_name is specified, and edge detection is enabled.
162 // create ImgDiff with default name. 167 // create ImgDiff with default name.
163 else if (EdgeDetectDegree > 0.0f) 168 else if (IgnoreEdge)
164 { 169 {
165 ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height()); 170 ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height());
166 } 171 }
167 return true; 172 return true;
168 } 173 }
169 174
170 void CompareArgs::Print_Args() 175 void CompareArgs::Print_Args()
171 { 176 {
172 printf("Field of view is %f degrees\n", FieldOfView); 177 printf("Field of view is %f degrees\n", FieldOfView);
173 printf("Threshold pixels is %d pixels\n", ThresholdPixels); 178 printf("Threshold pixels is %d pixels\n", ThresholdPixels);
174 printf("The Gamma is %f\n", Gamma); 179 printf("The Gamma is %f\n", Gamma);
175 printf("The Display's luminance is %f candela per meter squared\n", Lumi nance); 180 printf("The Display's luminance is %f candela per meter squared\n", Lumi nance);
176 } 181 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497