40 static int ParseParams(
programparams *Param,
int argc,
char *argv[]);
46 puts(
"Bilinear demosaicing demo, P. Getreuer 2010-2011\n");
47 puts(
"Usage: dmbilinear [options] <input file> <output file>\n"
50 puts(
" -p <pattern> CFA pattern, choices for <pattern> are");
51 puts(
" RGGB upperleftmost red pixel is at (0,0)");
52 puts(
" GRBG upperleftmost red pixel is at (1,0)");
53 puts(
" GBRG upperleftmost red pixel is at (0,1)");
54 puts(
" BGGR upperleftmost red pixel is at (1,1)");
56 puts(
" -q <number> Quality for saving JPEG images (0 to 100)\n");
59 " dmbilinear -p RGGB frog.bmp frog-dm.bmp");
63 int main(
int argc,
char *argv[])
66 float *Input = NULL, *Output = NULL;
67 int Width, Height, Status = 1;
70 if(!ParseParams(&Param, argc, argv))
74 if(!(Input = (
float *)
ReadImage(&Width, &Height,
78 if(Width < 2 || Height < 2)
80 ErrorMessage(
"Image is too small (%dx%d).\n", Width, Height);
84 if(!(Output = (
float *)
Malloc(
sizeof(
float)*3*
85 ((
long int)Width)*((
long int)Height))))
106 static int ParseParams(
programparams *Param,
int argc,
char *argv[])
108 static char *DefaultOutputFile = (
char *)
"out.bmp";
127 for(i = 1; i < argc;)
129 if(argv[i] && argv[i][0] ==
'-')
131 if((OptionChar = argv[i][1]) == 0)
138 OptionString = &argv[i][2];
140 OptionString = argv[i];
150 if(!strcmp(OptionString,
"RGGB")
151 || !strcmp(OptionString,
"rggb"))
156 else if(!strcmp(OptionString,
"GRBG")
157 || !strcmp(OptionString,
"grbg"))
162 else if(!strcmp(OptionString,
"GBRG")
163 || !strcmp(OptionString,
"gbrg"))
168 else if(!strcmp(OptionString,
"BGGR")
169 || !strcmp(OptionString,
"bggr"))
175 ErrorMessage(
"CFA pattern must be RGGB, GRBG, GBRG, or BGGR\n");
183 ErrorMessage(
"JPEG quality must be between 0 and 100.\n");
192 if(isprint(OptionChar))