35 fprintf(stderr, MSG "\n"); \
41 printf(
"\nquilting_main -p wp -r ratio -t tol -o overlap -s seed "
42 "src_im.png out_im.png pos_map.png synthesis_map.png\n\n");
43 printf(
"Required parameters:\n");
44 printf(
" src_im.png : name of the input PNG image\n");
45 printf(
" out_im.png : name of the output PNG image\n");
46 printf(
" pos_map.png : name of the position map PNG image\n");
47 printf(
" synthesis_map.png : name of the synthesis map PNG image\n\n");
48 printf(
"Optionnal parameters:\n");
49 printf(
" wp : int > size(src_im.png) that "
50 "specifies the size of the patch used to synthesize "
52 printf(
" ratio : float >= 1 that specifies the increase "
53 "of size of out_im.png relatively to the size "
55 printf(
" tol : float > 0 to specify the distance "
56 "tolerance when comparing patches in src_im.png\n");
57 printf(
" overlap : float 0 < o < 1 to specify the patch "
59 printf(
" seed : unsigned int to specify the seed "
60 "for the random number generator "
61 "(seed = time(NULL) by default)\n");
66 int main(
int argc,
char *argv[])
76 char *fname_positionMap;
77 char *fname_synthesisMap;
104 while ((c = getopt(argc, argv,
"p:r:t:o:s:h")) != -1) {
113 ratio = atof(optarg);
115 FATAL(
"Option usage: The ratio "
116 "specified by -r must be greater than 1.");
122 FATAL(
"Option usage: The tolerance error "
123 "specified by -t must be greater than 0.");
127 overlap = atof(optarg);
128 if (overlap <= 0. || overlap >= 1.)
129 FATAL(
"Option usage: The overlap ratio "
130 "specified by -o must be between 0. and 1.");
147 if (4 > (argc - optind)) {
148 printf(
"The input and output image file names are missing\n\n");
152 fname_in = argv[optind++];
153 fname_out = argv[optind++];
154 fname_positionMap = argv[optind++];
155 fname_synthesisMap = argv[optind++];
171 if((p_flag==1) && ((wp > (
int) src_im.
h) || (wp > (
int) src_im.
w)))
173 printf(
"Conflict: the patch size should be smaller "
174 "than the minimal length of the input image\n\n");
180 if((p_flag==1) && (wp==0))
182 printf(
"Conflict: the patch size should be greater than zero\n\n");
188 if ((wo = (
int) round(wp*overlap))<=0 || wo>=wp)
189 FATAL(
"Conflict: The patch overlap size should be at least one pixel "
190 "and less than the patch size");
194 int M = roundf(ratio*src_im.
h);
195 int N = roundf(ratio*src_im.
w);
198 if (src_im.
w < src_im.
h)
203 if (src_im.
h < src_im.
w)
208 p_row = (int) ceil(b/d);
209 p_col = (int) ceil(a/d);
223 tol, &pos_map, &synth_map, NULL);
226 tol, &pos_map, &synth_map, &seed);
229 Image synth_map_crop;
230 if (
crop_image(&synth_map_crop, &synth_map, M, N, 3))
232 FATAL(
"The size of the cropped image is bigger "
233 "than the image to crop");
238 if (
crop_image(&out_im_crop, &out_im, M, N, C))
240 FATAL(
"The size of the cropped image is bigger "
241 "than the image to crop");
246 pos_map.
w, pos_map.
h, pos_map.
c);
250 synth_map_crop.
w, synth_map_crop.
h, synth_map_crop.
c);
254 out_im_crop.
w, out_im_crop.
h, out_im_crop.
c);
259 free(synth_map_crop.
img);
262 free(out_im_crop.
img);