62 puts(
"ACE automatic color enhancement, P. Getreuer 2012");
64 printf(
"Using OpenMP with %d threads\n", omp_get_max_threads());
66 puts(
"\nSyntax: ace [options] <input file> <output file>\n\n"
69 puts(
" -a <number> alpha, stronger implies stronger enhancement");
70 puts(
" -w <omega> omega, spatial weighting function, choices are");
71 puts(
" 1/r default ACE, omega(x,y) = 1/sqrt(x^2+y^2)");
72 puts(
" 1 constant, omega(x,y) = 1");
73 puts(
" G:# Gaussian, where # specifies sigma,");
74 puts(
" omega(x,y) = exp(-(x^2+y^2)/(2 sigma^2))");
75 puts(
" -m <method> method to use for fast computation, choices are");
76 puts(
" interp:# interpolate s_a(L - I(x)) with # levels\n");
77 puts(
" poly:# polynomial s_a with degree #");
79 puts(
" -q <number> quality for saving JPEG images (0 to 100)\n");
82 puts(
" ace -a 5 -w 1/r -m interp:12 input.bmp output.bmp\n");
87 int main(
int argc,
char *argv[])
90 float *f = NULL, *u = NULL;
91 unsigned long time_start;
93 int status = 1, success;
95 if(!parse_params(¶m, argc, argv))
100 IMAGEIO_FLOAT | IMAGEIO_PLANAR | IMAGEIO_RGB)))
104 if(!(u = (
float *)
Malloc(
sizeof(
float)*3*
105 ((
long int)width)*((
long int)height))))
108 printf(
"Enhancing %dx%d image, alpha = %.4f, omega = %s\n",
111 printf(
"Using OpenMP with %d threads\n", omp_get_max_threads());
113 time_start = Clock();
118 printf(
"Interpolation with %d levels\n", param.
method_param);
124 printf(
"Degree %d polynomial approximation\n", param.
method_param);
135 printf(
"CPU Time: %.3f s\n", 0.001f*(Clock() - time_start));
139 IMAGEIO_FLOAT | IMAGEIO_PLANAR | IMAGEIO_RGB, param.
jpeg_quality))
143 printf(
"Output written to \"%s\".\n", param.
output_file);
157 static char *default_output_file = (
char *)
"out.bmp";
158 static char *default_omega = (
char *)
"1/r";
178 for(i = 1; i < argc;)
180 if(argv[i] && argv[i][0] ==
'-')
182 if((option_char = argv[i][1]) == 0)
189 option_string = &argv[i][2];
191 option_string = argv[i];
201 param->
alpha = atof(option_string);
209 param->
method = option_string;
211 if((method_param = strchr(param->
method,
':')))
213 *(method_param++) =
'\0';
219 if(!strcmp(param->
method,
"interp"))
230 else if(!strcmp(param->
method,
"poly"))
239 " 3, 5, 7, 9, or 11.\n");
258 ErrorMessage(
"JPEG quality must be between 0 and 100.\n");
267 if(isprint(option_char))