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

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» : Turns on edge detection, and ignore all edges in comparison\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 EdgeDetect = false; 58 » IgnoreEdge = false;
vangelis 2009/06/30 02:35:05 Please match the indentation of the rest of the it
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 » » } 89 » » } else if (strcmp(argv[i], "-ignoreEdges") == 0) {
87 » » //********************************************* 90 » » » if (++i < argc) {
88 » » // Add a new option as edgedetect 91 IgnoreEdge = true;
89 » » //********************************************* 92 » » » » EdgeNeighborNum = (float) atoi(argv[i]);
vangelis 2009/06/30 02:35:05 No need to have the comment above. Better to stay
90 » » else if (strcmp(argv[i], "-noedge") == 0) { 93 » » » » if (EdgeNeighborNum < 0)
91 » » » EdgeDetect = true; 94 » » » » » EdgeNeighborNum = 0;
92 » » } 95 » » » » if (EdgeNeighborNum > 7)
93 » » else if (strcmp(argv[i], "-verbose") == 0) { 96 » » » » » EdgeNeighborNum = 7;
97 » » » }
98 » » } else if (strcmp(argv[i], "-verbose") == 0) {
94 Verbose = true; 99 Verbose = true;
95 } else if (strcmp(argv[i], "-threshold") == 0) { 100 } else if (strcmp(argv[i], "-threshold") == 0) {
96 if (++i < argc) { 101 if (++i < argc) {
97 ThresholdPixels = atoi(argv[i]); 102 ThresholdPixels = atoi(argv[i]);
98 } 103 }
99 } else if (strcmp(argv[i], "-gamma") == 0) { 104 } else if (strcmp(argv[i], "-gamma") == 0) {
100 if (++i < argc) { 105 if (++i < argc) {
101 Gamma = (float) atof(argv[i]); 106 Gamma = (float) atof(argv[i]);
102 } 107 }
103 } else if (strcmp(argv[i], "-luminance") == 0) { 108 } else if (strcmp(argv[i], "-luminance") == 0) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (tmp) { 151 if (tmp) {
147 delete ImgA; 152 delete ImgA;
148 ImgA = tmp; 153 ImgA = tmp;
149 } 154 }
150 tmp = ImgB->DownSample(); 155 tmp = ImgB->DownSample();
151 if (tmp) { 156 if (tmp) {
152 delete ImgB; 157 delete ImgB;
153 ImgB = tmp; 158 ImgB = tmp;
154 } 159 }
155 } 160 }
156 » if(output_file_name) { 161
157 » » ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height(), o utput_file_name); 162 if(output_file_name) {
158 » } 163 ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height(),
159 else if (EdgeDetect) 164 output_file_name);
vangelis 2009/06/30 02:35:05 this doesn't allow us to use both an output file n
165 }
166 // if no output_file_name is specified, and edge detection is enabled.
167 // create ImgDiff with default name.
168 else if (IgnoreEdge)
160 { 169 {
161 ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height()); 170 ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height());
162 } 171 }
163 » return true; 172 return true;
164 } 173 }
165 174
166 void CompareArgs::Print_Args() 175 void CompareArgs::Print_Args()
167 { 176 {
168 printf("Field of view is %f degrees\n", FieldOfView); 177 printf("Field of view is %f degrees\n", FieldOfView);
169 printf("Threshold pixels is %d pixels\n", ThresholdPixels); 178 printf("Threshold pixels is %d pixels\n", ThresholdPixels);
170 printf("The Gamma is %f\n", Gamma); 179 printf("The Gamma is %f\n", Gamma);
171 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);
172 } 181 }
LEFTRIGHT

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