diff options
Diffstat (limited to 'src/gipfel.cxx')
-rw-r--r-- | src/gipfel.cxx | 92 |
1 files changed, 60 insertions, 32 deletions
diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 108c3ad..6df400f 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -46,19 +46,20 @@ Fl_Window *control_win, *view_win; Fl_Dial *s_center = NULL; Fl_Slider *s_nick, *s_focal_length, *s_tilt, *s_height_dist, *s_track_width; Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; -Fl_Value_Input *i_distortion_k0, *i_distortion_k1; +Fl_Value_Input *i_distortion_k0, *i_distortion_k1, *i_distortion_x0; Fl_Box *b_viewpoint; Fl_Menu_Bar *mb; -#define STITCH_PREVIEW 1 -#define STITCH_JPEG 2 -#define STITCH_TIFF 4 +#define STITCH_PREVIEW 1 +#define STITCH_JPEG 2 +#define STITCH_TIFF 4 -static int stitch(GipfelWidget::sample_mode_t m ,int stitch_w, int stitch_h, +static int stitch(GipfelWidget::sample_mode_t m , int b_16, + int stitch_w, int stitch_h, double from, double to, int type, const char *path, int argc, char **argv); void set_values() { - double k0 = 0.0, k1 = 0.0; + double k0 = 0.0, k1 = 0.0, x0 = 0.0; s_center->value(gipf->get_center_angle()); s_nick->value(gipf->get_nick_angle()); @@ -77,9 +78,10 @@ void set_values() { mb->mode(8, FL_MENU_RADIO); } - gipf->get_distortion_params(&k0, &k1); + gipf->get_distortion_params(&k0, &k1, &x0); i_distortion_k0->value(k0); i_distortion_k1->value(k1); + i_distortion_x0->value(x0); } void quit_cb() { @@ -174,14 +176,14 @@ void comp_cb(Fl_Widget *, void *) { void save_distortion_cb(Fl_Widget *, void *) { char buf[1024]; const char * prof_name; - double k0, k1; + double k0, k1, x0; buf[0] = '\0'; + gipf->get_distortion_params(&k0, &k1, &x0); - gipf->get_distortion_params(&k0, &k1); gipf->get_distortion_profile_name(buf, sizeof(buf)); - prof_name = fl_input("Save Distortion Profile (k0=%f, k1=%f)", - buf, k0, k1); + prof_name = fl_input("Save Distortion Profile (k0=%f, k1=%f, x0=%f)", + buf, k0, k1, x0); if (prof_name == NULL) { return; @@ -215,8 +217,10 @@ void load_distortion_cb(Fl_Widget *, void *) { } void distortion_cb(Fl_Value_Input*, void*) { - gipf->set_distortion_params(i_distortion_k0->value(), - i_distortion_k1->value()); + gipf->set_distortion_params( + i_distortion_k0->value(), + i_distortion_k1->value(), + i_distortion_x0->value()); } void about_cb() { @@ -260,6 +264,7 @@ void usage() { " -d <datafile> Use <datafile> for GPS data.\n" " -u <k0>,<k1> Use distortion correction values k0,k1.\n" " -s Stitch mode.\n" + " -4 Create 16bit output (only with TIFF stitching).\n" " -r <from>,<to> Stitch range in degrees (e.g. 100.0,200.0).\n" " -b Use bilinear interpolation for stitching.\n" " -w <width> Width of result image.\n" @@ -362,23 +367,31 @@ create_control_window() { i_view_height->when(FL_WHEN_ENTER_KEY); i_view_height->callback((Fl_Callback*)view_height_cb); - i_distortion_k0 = new Fl_Value_Input(235, 220, 80, 20, "Distortion (k0)"); + i_distortion_k0 = new Fl_Value_Input(250, 200, 80, 20, "k0"); i_distortion_k0->labelsize(10); i_distortion_k0->textsize(10); - i_distortion_k0->align(FL_ALIGN_TOP); + i_distortion_k0->align(FL_ALIGN_LEFT); i_distortion_k0->when(FL_WHEN_ENTER_KEY); i_distortion_k0->callback((Fl_Callback*)distortion_cb); - i_distortion_k1 = new Fl_Value_Input(315, 220, 80, 20, "Distortion (k1)"); + i_distortion_k1 = new Fl_Value_Input(250, 225, 80, 20, "k1"); i_distortion_k1->labelsize(10); i_distortion_k1->textsize(10); - i_distortion_k1->align(FL_ALIGN_TOP); + i_distortion_k1->align(FL_ALIGN_LEFT); i_distortion_k1->when(FL_WHEN_ENTER_KEY); i_distortion_k1->callback((Fl_Callback*)distortion_cb); + i_distortion_x0 = new Fl_Value_Input(250, 250, 80, 20, "x0"); + i_distortion_x0->labelsize(10); + i_distortion_x0->textsize(10); + i_distortion_x0->align(FL_ALIGN_LEFT); + i_distortion_x0->when(FL_WHEN_ENTER_KEY); + i_distortion_x0->callback((Fl_Callback*)distortion_cb); + + // Buttons - Fl_Button *b = new Fl_Button(260, 260, 100, 20, "comp"); + Fl_Button *b = new Fl_Button(280, 280, 100, 20, "comp"); b->color(FL_RED); b->tooltip("compute view parameter from given mountains"); b->callback(comp_cb); @@ -393,15 +406,15 @@ int main(int argc, char** argv) { int err, my_argc; int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; int jpeg_flag = 0, tiff_flag = 0, distortion_flag = 0; - int bilinear_flag = 0; + int bicubic_flag = 0, b_16_flag = 0; double stitch_from = 0.0, stitch_to = 380.0; - double dist_k0 = 0.0, dist_k1 = 0.0; + double dist_k0 = 0.0, dist_k1 = 0.0, dist_x0 = 0.0; char *outpath = "/tmp"; Fl_Scroll *scroll; err = 0; - while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:")) != EOF) { + while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:4")) != EOF) { switch (c) { case '?': usage(); @@ -416,6 +429,9 @@ int main(int argc, char** argv) { case 's': stitch_flag++; break; + case '4': + b_16_flag++; + break; case 'r': stitch_flag++; if (optarg && strcmp(optarg, ":")) { @@ -426,11 +442,17 @@ int main(int argc, char** argv) { } break; case 'u': + char *c; distortion_flag++; if (optarg && strcmp(optarg, ":")) { dist_k0 = atof(optarg); - if (strchr(optarg, ',')) { + c = strchr(optarg, ','); + if (c) { dist_k1 = atof(strchr(optarg, ',') + 1); + c = strchr(c + 1, ','); + if (c) { + dist_x0 = atof(strchr(optarg, ',') + 1); + } } } break; @@ -449,7 +471,7 @@ int main(int argc, char** argv) { stitch_h = atoi(optarg); break; case 'b': - bilinear_flag++; + bicubic_flag++; break; default: err++; @@ -470,14 +492,17 @@ int main(int argc, char** argv) { } if (stitch_flag) { - int type = STITCH_PREVIEW; + int type = 0; if (jpeg_flag) { type = STITCH_JPEG; } else if (tiff_flag) { type = STITCH_TIFF; + } else { + type = STITCH_PREVIEW; } - stitch(bilinear_flag?GipfelWidget::BILINEAR:GipfelWidget::NEAREST, + stitch(bicubic_flag?GipfelWidget::BICUBIC:GipfelWidget::NEAREST, + b_16_flag, stitch_w, stitch_h, stitch_from, stitch_to, type, outpath, my_argc, my_argv); @@ -508,7 +533,7 @@ int main(int argc, char** argv) { } if (distortion_flag) { - gipf->set_distortion_params(dist_k0, dist_k1); + gipf->set_distortion_params(dist_k0, dist_k1, dist_x0); } view_win->size(gipf->w(), gipf->h()); @@ -536,7 +561,7 @@ int main(int argc, char** argv) { } static int -stitch(GipfelWidget::sample_mode_t m, +stitch(GipfelWidget::sample_mode_t m, int b_16, int stitch_w, int stitch_h, double from, double to, int type, const char *path, int argc, char **argv) { @@ -548,12 +573,13 @@ stitch(GipfelWidget::sample_mode_t m, st->load_image(argv[i]); } - if (type == STITCH_JPEG) { - st->set_output((OutputImage*) new JPEGOutputImage(path, 90)); + if (type & STITCH_JPEG) { + + st->set_output(new JPEGOutputImage(path, 90)); st->resample(m, stitch_w, stitch_h, from, to); - } else if (type == STITCH_TIFF) { + } else if (type & STITCH_TIFF) { for (int i=0; i<argc; i++) { char buf[1024]; @@ -566,7 +592,7 @@ stitch(GipfelWidget::sample_mode_t m, } strncat(buf, ".tiff", sizeof(buf)); - st->set_output(argv[i], (OutputImage*) new TIFFOutputImage(buf)); + st->set_output(argv[i], new TIFFOutputImage(buf, b_16?16:8)); } st->resample(m, stitch_w, stitch_h, from, to); @@ -579,8 +605,10 @@ stitch(GipfelWidget::sample_mode_t m, win->resizable(scroll); win->show(0, argv); - st->set_output((OutputImage*) img); + st->set_output(img); + st->resample(m, stitch_w, stitch_h, from, to); + img->redraw(); Fl::run(); } |