60 static int ParseParams(
programparams *Param,
int argc,
char *argv[]);
63 static void PrintHelpMessage()
65 puts(
"Image Interpolation with Contour Stencils, P. Getreuer 2010-2011\n");
66 puts(
"Usage: cwinterp [options] <input file> <output file>\n\n"
69 puts(
" -x <number> the scale factor (may be non-integer)");
70 puts(
" -p <number> sigma_h, the blur size of the point spread function");
71 puts(
" -g <grid> grid to use for resampling, choices for <grid> are\n"
72 " centered grid with centered alignment (default)\n"
73 " topleft the top-left anchored grid\n");
75 "show the estimated orientations instead of interpolating\n");
76 puts(
" -t <number> sigma_tau, spread of phi in the tagential direction");
77 puts(
" -n <number> sigma_nu, spread of phi in the normal direction");
78 puts(
" -r <number> the number of refinement passes\n");
80 puts(
" -q <number> quality for saving JPEG images (0 to 100)\n");
82 puts(
"Example: 4x scaling, sigma_h = 0.35, 2 refinement passes\n"
83 " cwinterp -x 4 -p 0.35 -r 2 frog.bmp frog-4x.bmp");
86 int main(
int argc,
char *argv[])
89 image v = {NULL, 0, 0}, u = {NULL, 0, 0};
95 if(!ParseParams(&Param, argc, argv))
112 if(!(u.Data = (uint32_t *)
Malloc(
sizeof(uint32_t)*
113 ((
long int)u.Width)*((
long int)u.Height))))
120 printf(
"Integer scale factor %dx%d input -> %dx%d output\n",
129 printf(
"Arbitrary scale factor %dx%d input -> %dx%d output\n",
153 printf(
"Output written to \"%s\".\n", Param.
OutputFile);
168 static int ParseParams(
programparams *Param,
int argc,
char *argv[])
170 static char *DefaultOutputFile = (
char *)
"out.bmp";
197 for(i = 1; i < argc;)
199 if(argv[i] && argv[i][0] ==
'-')
201 if((OptionChar = argv[i][1]) == 0)
208 OptionString = &argv[i][2];
210 OptionString = argv[i];
224 ErrorMessage(
"Scale factor cannot be less than 1.0.\n");
229 if(!strcmp(OptionString,
"centered")
230 || !strcmp(OptionString,
"center"))
232 else if(!strcmp(OptionString,
"topleft")
233 || !strcmp(OptionString,
"top-left"))
237 ErrorMessage(
"Grid must be either \"centered\" or \"topleft\".\n");
255 ErrorMessage(
"Point spread blur size must be nonnegative.\n");
288 Param->
TestFlag = atoi(OptionString);
297 ErrorMessage(
"JPEG quality must be between 0 and 100.\n");
306 if(isprint(OptionChar))
342 printf(
"centered grid, ");
344 printf(
"top-left grid, ");
347 printf(
"1 refinement pass,");
351 printf(
"\nsigma_h = %g, sigma_tau = %g, sigma_nu = %g\n",