From 3d907fd76ca23d69bcd7d25367c9c94063490d38 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 13 Mar 2007 18:29:45 +0100 Subject: add devignetting infrastructure --- src/Stitch.H | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index dcfc691..13e7bc0 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -33,6 +33,9 @@ class Stitch { int resample(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end); + + int vignette_calib(GipfelWidget::sample_mode_t m, + int w, int h, double view_start, double view_end); }; #endif -- cgit v1.2.3 From 905cd5600e604aa1f9fe256ab3b4d7125695951e Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 15 Mar 2007 00:25:29 +0100 Subject: add color and brightness adjustment --- src/Stitch.H | 7 +- src/Stitch.cxx | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- src/gipfel.cxx | 4 +- 3 files changed, 201 insertions(+), 11 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index 13e7bc0..62175be 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -13,13 +13,15 @@ #define MAX_PICS 256 + class Stitch { private: GipfelWidget *gipf[MAX_PICS]; + double color_adjust[MAX_PICS][3]; + double V1, V2; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; - public: Stitch(); @@ -34,6 +36,9 @@ class Stitch { int resample(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end); + int color_calib(GipfelWidget::sample_mode_t m, + int w, int h, double view_start, double view_end); + int vignette_calib(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end); }; diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 54d2272..dbd0d53 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -28,6 +28,9 @@ Stitch::Stitch() { single_images[i] = NULL; } merged_image = NULL; + V1 = 0.213895; + V2 = 0.089561; + } Stitch::~Stitch() { @@ -82,6 +85,183 @@ Stitch::set_output(const char *file, OutputImage *img) { return ret; } +typedef struct { + int c1[3]; + int c2[3]; +} sample_t; + +static int +get_color_adjust(const sample_t *samples, int n_samples, + const double *color_adjust_1, double *color_adjust_2) { + + gsl_matrix *X, *cov; + gsl_vector *yv, *r; + double chisq; + + X = gsl_matrix_alloc(n_samples, 1); + yv = gsl_vector_alloc(n_samples); + r = gsl_vector_alloc(1); + cov = gsl_matrix_alloc (1, 1); + + for (int c = 0; c<3; c++) { + for (int i = 0; i< n_samples; i++) { + gsl_matrix_set(X, i, 0, samples[i].c2[c]); + gsl_vector_set(yv, i, samples[i].c1[c] * color_adjust_1[c]); + } + + + gsl_multifit_linear_workspace * work + = gsl_multifit_linear_alloc (n_samples, 1); + + gsl_multifit_linear (X, yv, r, cov, &chisq, work); + gsl_multifit_linear_free (work); + + color_adjust_2[c] = gsl_vector_get(r,0); + } + + return 0; + +} + + + +int +Stitch::color_calib(GipfelWidget::sample_mode_t m, + int w, int h, double view_start, double view_end) { + + sample_t * sample_points[MAX_PICS][MAX_PICS]; + + memset(sample_points, 0, sizeof(sample_points)); + + view_start = view_start * deg2rad; + view_end = view_end * deg2rad; + + double step_view = (view_end - view_start) / w; + uchar r, g, b; + int y_off = h / 2; + int merged_pixel_set; + double radius = (double) w / (view_end -view_start); + + if (merged_image) { + merged_image->init(w, h); + } + + for(int j=0; j<3; j++) { + color_adjust[0][j] = 1.0; + } + + for (int i=1; iget_pixel(m, a_view, a_nick, + &c1[0], &c1[1], &c1[2]) == 0) { + + double a1 = gipf[p1]->get_angle_off(a_view, a_nick); + double devign = ( 1 + a1 * a1 * V2 + a1*a1*a1*a1 * V1); + for (int l=0; l<3;l++) { + c1[l]=((uchar)MIN(rint((double) c1[l] * devign), 255)); + } + + for (int p2=0; p2get_pixel(m, a_view, a_nick, + &c2[0], &c2[1], &c2[2]) == 0) { + double a2 = gipf[p2]->get_angle_off(a_view, a_nick); + devign = ( 1 + a2 * a2 * V2 + a2*a2*a2*a2 * V1); + for (int l=0; l<3;l++) { + c2[l]=((uchar)MIN(rint((double) c2[l] * devign), 255)); + } + + if (fabs(a1-a2) < 0.02 && + fabs(((double) c1[1]) / ((double) c1[0]) - + ((double) c2[1]) / ((double) c2[0])) < 1.0 && + fabs(((double) c1[2]) / ((double) c1[0]) - + ((double) c2[2]) / ((double) c2[0])) < 1.0) { + + if (sample_points[p1][p2] == NULL) { + fprintf(stderr, "allocated sample_points [%d][%d]\n", p1, p2); + sample_points[p1][p2] = (sample_t*) + calloc(500, sizeof(sample_t)); + } + + for (int k=0; k < 500; k++) { + if (sample_points[p1][p2][k].c1[0] == 0) { + for (int l=0; l < 3; l++) { + sample_points[p1][p2][k].c1[l] = c1[l]; + sample_points[p1][p2][k].c2[l] = c2[l]; + } + break; + } + + } + + if (merged_image) { + merged_image->set_pixel(x, 255, 0, 0); + merged_pixel_set++; + } + + + } + } + } + + + if (!merged_pixel_set && merged_image) { + merged_image->set_pixel(x, c1[0], c1[1], c1[2]); + } + } + } + } + if (merged_image) { + merged_image->next_line(); + } + } + + if (merged_image) { + merged_image->done(); + } + + for (int n=0; n<20; n++) { + for (int i=0; i 0.0) { + for (int j=1; j Adjust %d: %lf %lf %lf\n", j, color_adjust[j][0], color_adjust[j][1], color_adjust[j][2]); + } + } + + } + } + } + + + return 0; +} + + int Stitch::vignette_calib(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end) { @@ -126,7 +306,9 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, break; } else if (gipf[i]->get_pixel(m, a_view, a_nick, &c2[0], &c2[1], &c2[2]) == 0) { - l2 = (double) c2[0] + (double) c2[1] + (double) c2[2]; + l2 = (double) c2[0] * color_adjust[i][0] + + (double) c2[1] * color_adjust[i][1] + + (double) c2[2] * color_adjust[i][2]; a2 = gipf[i]->get_angle_off(a_view, a_nick); if (l1 > 0.0) { @@ -136,9 +318,9 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, c1[0] < 200 && c1[1] < 200 && c1[2] < 200 && c2[0] < 200 && c2[1] < 200 && c2[2] < 200 && fabs(((double) c1[1]) / ((double) c1[0]) - - ((double) c2[1]) / ((double) c2[0])) < 0.02 && + ((double) c2[1]) / ((double) c2[0])) < 0.05 && fabs(((double) c1[2]) / ((double) c1[0]) - - ((double) c2[2]) / ((double) c2[0])) < 0.02) { + ((double) c2[2]) / ((double) c2[0])) < 0.05) { gsl_matrix_set(X, n_samples, 0, l2 * a2 * a2 *a2 * a2 - l1 * a1 *a1 *a1 * a1); gsl_matrix_set(X, n_samples, 1, l2 * a2 * a2 - l1 * a1 * a1); @@ -146,7 +328,6 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, n_samples++; if (merged_image) { - double V1 = -0.57301, V2 = 0.85233; double d = fabs(V2 * (l2 * a2 * a2 - l1 * a1 * a1) + V1 * (l2 * a2 * a2 *a2 - l1 * a1 * a1 *a1) - (l1 -l2)); merged_image->set_pixel(x, (uchar) rint(d * 2), 0, 0); @@ -184,8 +365,11 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, gsl_multifit_linear (X, yv, c, cov, &chisq, work); gsl_multifit_linear_free (work); + V1 = gsl_vector_get(c,0); + V2 = gsl_vector_get(c,1); + fprintf(stderr, "===> v1 %lf v2 %lf, (i %d)\n", - gsl_vector_get(c,0),gsl_vector_get(c,1), n_samples); + V1, V2, n_samples); return 0; } @@ -203,7 +387,6 @@ Stitch::resample(GipfelWidget::sample_mode_t m, int y_off = h / 2; int merged_pixel_set; double radius = (double) w / (view_end -view_start); - double V1 = 0.213895, V2 = 0.089561; if (merged_image) { merged_image->init(w, h); @@ -231,9 +414,9 @@ Stitch::resample(GipfelWidget::sample_mode_t m, double devign = ( 1 + a2 * a2 * V2 + a2*a2*a2*a2 * V1); #if 1 - r = (uchar) MIN(rint((double) r * devign), 255); - g = (uchar) MIN(rint((double) g * devign), 255); - b = (uchar) MIN(rint((double) b * devign), 255); + r = (uchar) MIN(rint(((double) r) * devign * color_adjust[i][0]), 255); + g = (uchar) MIN(rint(((double) g) * devign * color_adjust[i][1]), 255); + b = (uchar) MIN(rint(((double) b) * devign * color_adjust[i][2]), 255); #else r = (uchar) MIN(rint((double) 100 * devign), 255); diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 584ae15..7aad38f 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -596,7 +596,9 @@ stitch(GipfelWidget::sample_mode_t m, st->set_output((OutputImage*) img); if (type == STITCH_VIGNETTE_CALIB) { - st->vignette_calib(m, stitch_w, stitch_h, from, to); + st->color_calib(m, stitch_w, stitch_h, from, to); + //st->vignette_calib(m, stitch_w, stitch_h, from, to); + st->resample(m, stitch_w, stitch_h, from, to); } else { st->resample(m, stitch_w, stitch_h, from, to); } -- cgit v1.2.3 From 5fd1230803fddcfb8e3cfb38608221ef52c0f104 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 16 Mar 2007 15:20:43 +0100 Subject: try linear version - does not work yet --- src/Stitch.H | 9 +- src/Stitch.cxx | 321 +++++++++++++++++---------------------------------------- src/gipfel.cxx | 7 +- 3 files changed, 99 insertions(+), 238 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index 62175be..29f0ef3 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -17,11 +17,13 @@ class Stitch { private: GipfelWidget *gipf[MAX_PICS]; - double color_adjust[MAX_PICS][3]; - double V1, V2; + int num_pics; + double color_adjust[MAX_PICS][3][3]; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; + uchar color_correct(uchar c, double a, int pic, int color); + public: Stitch(); @@ -36,9 +38,6 @@ class Stitch { int resample(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end); - int color_calib(GipfelWidget::sample_mode_t m, - int w, int h, double view_start, double view_end); - int vignette_calib(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end); }; diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 1391fff..113dc62 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -28,8 +28,7 @@ Stitch::Stitch() { single_images[i] = NULL; } merged_image = NULL; - V1 = 0.213895; - V2 = 0.089561; + num_pics = 0; } @@ -52,6 +51,8 @@ Stitch::load_image(char *file) { if (gipf[i]->load_image(file) != 0) { delete gipf[i]; gipf[i] = NULL; + } else { + num_pics++; } break; } @@ -85,54 +86,11 @@ Stitch::set_output(const char *file, OutputImage *img) { return ret; } -typedef struct { - int c1[3]; - int c2[3]; -} sample_t; - -static int -get_color_adjust(const sample_t *samples, int n_samples, - const double *color_adjust_1, double *color_adjust_2) { - - gsl_matrix *X, *cov; - gsl_vector *yv, *r; - double chisq; - - X = gsl_matrix_alloc(n_samples, 1); - yv = gsl_vector_alloc(n_samples); - r = gsl_vector_alloc(1); - cov = gsl_matrix_alloc (1, 1); - - for (int c = 0; c<3; c++) { - for (int i = 0; i< n_samples; i++) { - gsl_matrix_set(X, i, 0, samples[i].c2[c]); - gsl_vector_set(yv, i, samples[i].c1[c] * color_adjust_1[c]); - } - - - gsl_multifit_linear_workspace * work - = gsl_multifit_linear_alloc (n_samples, 1); - - gsl_multifit_linear (X, yv, r, cov, &chisq, work); - gsl_multifit_linear_free (work); - - color_adjust_2[c] = gsl_vector_get(r,0); - } - - return 0; - -} - - int -Stitch::color_calib(GipfelWidget::sample_mode_t m, +Stitch::vignette_calib(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end) { - sample_t * sample_points[MAX_PICS][MAX_PICS]; - - memset(sample_points, 0, sizeof(sample_points)); - view_start = view_start * deg2rad; view_end = view_end * deg2rad; @@ -142,18 +100,20 @@ Stitch::color_calib(GipfelWidget::sample_mode_t m, int merged_pixel_set; double radius = (double) w / (view_end -view_start); - if (merged_image) { - merged_image->init(w, h); - } + int max_samples = 10 * 3, n_samples = 0; + int ret; + int n_vars = (num_pics-1) * 9; + gsl_matrix *X, *cov; + gsl_vector *yv, *c; + double chisq; - for(int j=0; j<3; j++) { - color_adjust[0][j] = 1.0; - } + X = gsl_matrix_alloc(max_samples, n_vars); + yv = gsl_vector_alloc(max_samples); + c = gsl_vector_alloc(n_vars); + cov = gsl_matrix_alloc (n_vars, n_vars); - for (int i=1; iinit(w, h); } for (int y=0; yget_pixel(m, a_view, a_nick, &c1[0], &c1[1], &c1[2]) == 0) { - double a1 = gipf[p1]->get_angle_off(a_view, a_nick); - double devign = ( 1 + a1 * a1 * V2 + a1*a1*a1*a1 * V1); - for (int l=0; l<3;l++) { - c1[l]=((uchar)MIN(rint((double) c1[l] * devign), 255)); + for (int l = 0; l<3; l++) { + c1d[l] = (double) c1[l]; } - for (int p2=0; p2get_angle_off(a_view, a_nick); + for (int p2=1; p2get_pixel(m, a_view, a_nick, &c2[0], &c2[1], &c2[2]) == 0) { - double a2 = gipf[p2]->get_angle_off(a_view, a_nick); - devign = ( 1 + a2 * a2 * V2 + a2*a2*a2*a2 * V1); - for (int l=0; l<3;l++) { - c2[l]=((uchar)MIN(rint((double) c2[l] * devign), 255)); - } - if (fabs(a1-a2) < 0.01 && - fabs(((double) c1[1]) / ((double) c1[0]) - - ((double) c2[1]) / ((double) c2[0])) < 1.0 && - fabs(((double) c1[2]) / ((double) c1[0]) - - ((double) c2[2]) / ((double) c2[0])) < 1.0) { - - if (sample_points[p1][p2] == NULL) { - fprintf(stderr, "allocated sample_points [%d][%d]\n", p1, p2); - sample_points[p1][p2] = (sample_t*) - calloc(500, sizeof(sample_t)); - } + for (int l = 0; l<3; l++) { + c2d[l] = (double) c2[l]; + } - for (int k=0; k < 500; k++) { - if (sample_points[p1][p2][k].c1[0] == 0) { - for (int l=0; l < 3; l++) { - sample_points[p1][p2][k].c1[l] = c1[l]; - sample_points[p1][p2][k].c2[l] = c2[l]; - } - break; + a2 = gipf[p2]->get_angle_off(a_view, a_nick); + + if (n_samples < max_samples && + c1[0] < 200 && c1[1] < 200 && c1[2] < 200 && + c2[0] < 200 && c2[1] < 200 && c2[2] < 200 && + c1[0] > 20 && c1[1] > 20 && c1[2] > 20 && + c2[0] > 20 && c2[1] > 20 && c2[2] > 20 && + fabs(c1d[1] / c1d[0] - c2d[1] / c2d[0]) < 0.01 && + fabs(c1d[2] / c1d[0] - c2d[2] / c2d[0]) < 0.01 ) { + + for (int l = 0; l<3; l++) { + gsl_matrix_set_zero(X); + if (p1 == 0) { +fprintf(stderr, "==> p1 = 0 p2 = %d\n", p2); + // gsl_matrix_set(X, n_samples, (p2-1) * 9 + 3 * l + 2, c2d[l] * a2 *a2 * a2 * a2); + // gsl_matrix_set(X, n_samples, (p2-1) * 9 + 3 * l + 1, c2d[l] * a2 * a2); + gsl_matrix_set(X, n_samples, (p2-1) * 9 + 3 * l + 0, c2d[l]); + gsl_vector_set(yv, n_samples, c1d[l]); + } else { + // gsl_matrix_set(X, n_samples, (p1-1) * 9 + 3 * l + 2, - c1d[l] * a1 *a1 * a1 * a1); + // gsl_matrix_set(X, n_samples, (p2-1) * 9 + 3 * l + 2, c2d[l] * a2 * a2 * a2 * a2); + // gsl_matrix_set(X, n_samples, (p1-1) * 9 + 3 * l + 1, - c1d[l] * a1 * a1); + // gsl_matrix_set(X, n_samples, (p2-1) * 9 + 3 * l + 1, c2d[l] * a2 * a2); + gsl_matrix_set(X, n_samples, (p1-1) * 9 + 3 * l + 0, - c1d[l]); + gsl_matrix_set(X, n_samples, (p2-1) * 9 + 3 * l + 0, c2d[l]); + gsl_vector_set(yv, n_samples, 0.0); } - + n_samples++; } - + if (merged_image) { merged_image->set_pixel(x, 255, 0, 0); merged_pixel_set++; } - - } + } } - if (!merged_pixel_set && merged_image) { merged_image->set_pixel(x, c1[0], c1[1], c1[2]); + merged_pixel_set++; } + } } } @@ -240,141 +206,47 @@ Stitch::color_calib(GipfelWidget::sample_mode_t m, if (merged_image) { merged_image->done(); } - - for (int n=0; n<20; n++) { - for (int i=0; i 0.0) { - for (int j=1; j Adjust %d: %lf %lf %lf\n", j, color_adjust[j][0], color_adjust[j][1], color_adjust[j][2]); - } +gsl_vector_fprintf(stderr, yv, "%f"); + gsl_multifit_linear_workspace * work + = gsl_multifit_linear_alloc (n_samples, n_vars); + + ret = gsl_multifit_linear (X, yv, c, cov, &chisq, work); + gsl_multifit_linear_free (work); + + fprintf(stderr, "gsl_multifit_linear returned %d\n", ret); + + for (int p1=0; p1 < num_pics; p1++) { + for (int l = 0; l<3; l++) { + if (p1 == 0) { + color_adjust[p1][l][0] = 1.0; + color_adjust[p1][l][1] = 0.0; + color_adjust[p1][l][2] = 0.0; + } else { + for (int k = 0; k<3; k++) { + color_adjust[p1][l][k] = gsl_vector_get(c, (p1-1) * 9 + 3 * l + k); } - + color_adjust[p1][l][1] = 0.0; + color_adjust[p1][l][2] = 0.0; } } - } - +fprintf(stderr, "==> color_adjust(%d) %f %f %f\n", p1, color_adjust[p1][0][0], color_adjust[p1][1][0],color_adjust[p1][2][0]); + } return 0; } +uchar +Stitch::color_correct(uchar c, double a, int pic, int color) { + double cd = (double) c; + + cd = cd * ( + color_adjust[pic][color][0] + + color_adjust[pic][color][1] * a * a + + color_adjust[pic][color][2] * a * a * a * a); -int -Stitch::vignette_calib(GipfelWidget::sample_mode_t m, - int w, int h, double view_start, double view_end) { - - view_start = view_start * deg2rad; - view_end = view_end * deg2rad; - - double step_view = (view_end - view_start) / w; - uchar r, g, b; - int y_off = h / 2; - int merged_pixel_set; - double radius = (double) w / (view_end -view_start); - - int max_samples = 10000, n_samples = 0; - gsl_matrix *X, *cov; - gsl_vector *yv, *c; - double chisq; - - X = gsl_matrix_alloc(max_samples, 2); - yv = gsl_vector_alloc(max_samples); - c = gsl_vector_alloc(2); - cov = gsl_matrix_alloc (2, 2); - - if (merged_image) { - merged_image->init(w, h); - } - - for (int y=0; yget_pixel(m, a_view, a_nick, - &c2[0], &c2[1], &c2[2]) == 0) { - l2 = (double) c2[0] * color_adjust[i][0] + - (double) c2[1] * color_adjust[i][1] + - (double) c2[2] * color_adjust[i][2]; - a2 = gipf[i]->get_angle_off(a_view, a_nick); - - if (l1 > 0.0) { - - if (n_samples < max_samples && - fabs(a1 - a2) > 0.02 && - c1[0] < 200 && c1[1] < 200 && c1[2] < 200 && - c2[0] < 200 && c2[1] < 200 && c2[2] < 200 && - fabs(((double) c1[1]) / ((double) c1[0]) - - ((double) c2[1]) / ((double) c2[0])) < 0.05 && - fabs(((double) c1[2]) / ((double) c1[0]) - - ((double) c2[2]) / ((double) c2[0])) < 0.05) { - - gsl_matrix_set(X, n_samples, 0, l2 * a2 * a2 *a2 * a2 - l1 * a1 *a1 *a1 * a1); - gsl_matrix_set(X, n_samples, 1, l2 * a2 * a2 - l1 * a1 * a1); - gsl_vector_set(yv, n_samples, l1 - l2); - n_samples++; - - if (merged_image) { - double d = fabs(V2 * (l2 * a2 * a2 - l1 * a1 * a1) + V1 * (l2 * a2 * a2 *a2 - l1 * a1 * a1 *a1) - (l1 -l2)); - - merged_image->set_pixel(x, (uchar) rint(d * 2), 0, 0); - merged_pixel_set++; - } - - - } - } - - l1 = l2; - a1 = a2; - c1[0] = c2[0]; - c1[1] = c2[1]; - c1[2] = c2[2]; - - if (!merged_pixel_set && merged_image) { - merged_image->set_pixel(x, c1[0], c1[1], c1[2]); - } - } - } - } - if (merged_image) { - merged_image->next_line(); - } - } - - if (merged_image) { - merged_image->done(); - } - - gsl_multifit_linear_workspace * work - = gsl_multifit_linear_alloc (n_samples, 2); - - gsl_multifit_linear (X, yv, c, cov, &chisq, work); - gsl_multifit_linear_free (work); - - V1 = gsl_vector_get(c,0); - V2 = gsl_vector_get(c,1); - - fprintf(stderr, "===> v1 %lf v2 %lf, (i %d)\n", - V1, V2, n_samples); - - return 0; + return (uchar) MIN(rint(cd), 255.0); } - int Stitch::resample(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end) { @@ -410,20 +282,11 @@ Stitch::resample(GipfelWidget::sample_mode_t m, break; } else if (gipf[i]->get_pixel(m, a_view, a_nick, &r, &g, &b) == 0) { - double a2 = gipf[i]->get_angle_off(a_view, a_nick); - double devign = ( 1 + a2 * a2 * V2 + a2*a2*a2*a2 * V1); - -#if 1 - r = (uchar) MIN(rint(((double) r) * devign * color_adjust[i][0]), 255); - g = (uchar) MIN(rint(((double) g) * devign * color_adjust[i][1]), 255); - b = (uchar) MIN(rint(((double) b) * devign * color_adjust[i][2]), 255); -#else - - r = (uchar) MIN(rint((double) 100 * devign), 255); - g = (uchar) MIN(rint((double) 100 * devign), 255); - b = (uchar) MIN(rint((double) 100 * devign), 255); -#endif + double a = gipf[i]->get_angle_off(a_view, a_nick); + r = color_correct(r, a, i, 0); + g = color_correct(g, a, i, 1); + b = color_correct(b, a, i, 2); if (single_images[i]) { single_images[i]->set_pixel(x, r, g, b); diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 23a5c5f..e9743d8 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -568,10 +568,6 @@ stitch(GipfelWidget::sample_mode_t m, st->load_image(argv[i]); } - if (type & STITCH_VIGNETTE_CALIB) { - st->color_calib(m, stitch_w, stitch_h, from, to); - //st->vignette_calib(m, stitch_w, stitch_h, from, to); - } if (type & STITCH_JPEG) { @@ -604,6 +600,9 @@ stitch(GipfelWidget::sample_mode_t m, win->show(0, argv); st->set_output((OutputImage*) img); + if (type & STITCH_VIGNETTE_CALIB) { + st->vignette_calib(m, stitch_w, stitch_h, from, to); + } st->resample(m, stitch_w, stitch_h, from, to); img->redraw(); -- cgit v1.2.3 From 8cba58d9aa6b4f92fe90231966f58ad0435f1d3f Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 16 Mar 2007 17:13:56 +0100 Subject: try other model --- src/Stitch.H | 3 ++- src/Stitch.cxx | 50 +++++++++++++++++++++++--------------------------- 2 files changed, 25 insertions(+), 28 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index 29f0ef3..9fe3c15 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -18,7 +18,8 @@ class Stitch { private: GipfelWidget *gipf[MAX_PICS]; int num_pics; - double color_adjust[MAX_PICS][3][3]; + double color_adjust[MAX_PICS][3]; + double V1, V2; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 3bb39e9..b2053fe 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -87,8 +87,8 @@ Stitch::set_output(const char *file, OutputImage *img) { } static int -var_offset(int pic, int color, int pow) { - return 9 * (pic - 1) + 3 * color + pow; +var_offset(int pic, int color) { + return 2 + (pic - 1) * 3 + color; } int @@ -104,9 +104,9 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, int merged_pixel_set; double radius = (double) w / (view_end -view_start); - int max_samples = 10000 * 3, n_samples = 0; + int max_samples = 5000 * 3, n_samples = 0; int ret; - int n_vars = (num_pics-1) * 9; + int n_vars = 2 + (num_pics-1) * 3 ; gsl_matrix *X, *cov; gsl_vector *yv, *c; double chisq; @@ -162,23 +162,23 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, c1[0] < 200 && c1[1] < 200 && c1[2] < 200 && c2[0] < 200 && c2[1] < 200 && c2[2] < 200 && c1[0] > 20 && c1[1] > 20 && c1[2] > 20 && - c2[0] > 20 && c2[1] > 20 && c2[2] > 20) { - // fabs(c1d[1] / c1d[0] - c2d[1] / c2d[0]) < 0.01 && - // fabs(c1d[2] / c1d[0] - c2d[2] / c2d[0]) < 0.01 ) { + c2[0] > 20 && c2[1] > 20 && c2[2] > 20 && + fabs(c1d[1] / c1d[0] - c2d[1] / c2d[0]) < 0.02 && + fabs(c1d[2] / c1d[0] - c2d[2] / c2d[0]) < 0.02 ) { for (int l = 0; l<3; l++) { - if (p1 == 0) { - gsl_matrix_set(X, n_samples, var_offset(p2, l, 2), c2d[l] * a2 *a2 * a2 * a2); - gsl_matrix_set(X, n_samples, var_offset(p2, l, 1), c2d[l] * a2 * a2); - gsl_matrix_set(X, n_samples, var_offset(p2, l, 0), c2d[l]); + if ( p1 == 0) { + gsl_matrix_set(X, n_samples, 0, c2d[l] * a2 * a2); + gsl_matrix_set(X, n_samples, 1, c2d[l] * a2 *a2 * a2 * a2); + gsl_matrix_set(X, n_samples, var_offset(p2, l), c2d[l]); gsl_vector_set(yv, n_samples, c1d[l]); } else { - gsl_matrix_set(X, n_samples, var_offset(p1, l, 2), - c1d[l] * a1 *a1 * a1 * a1); - gsl_matrix_set(X, n_samples, var_offset(p2, l, 2), c2d[l] * a2 * a2 * a2 * a2); - gsl_matrix_set(X, n_samples, var_offset(p1, l, 1), - c1d[l] * a1 * a1); - gsl_matrix_set(X, n_samples, var_offset(p2, l, 1), c2d[l] * a2 * a2); - gsl_matrix_set(X, n_samples, var_offset(p1, l, 0), - c1d[l]); - gsl_matrix_set(X, n_samples, var_offset(p2, l, 0), c2d[l]); + gsl_matrix_set(X, n_samples, 0, - c1d[l] * a1 * a1); + gsl_matrix_set(X, n_samples, 0, c2d[l] * a2 * a2); + gsl_matrix_set(X, n_samples, 1, - c1d[l] * a1 *a1 * a1 * a1); + gsl_matrix_set(X, n_samples, 1, c2d[l] * a2 * a2 * a2 * a2); + gsl_matrix_set(X, n_samples, var_offset(p1, l), - c1d[l]); + gsl_matrix_set(X, n_samples, var_offset(p2, l), c2d[l]); gsl_vector_set(yv, n_samples, 0.0); } n_samples++; @@ -221,16 +221,12 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, for (int p1=0; p1 < num_pics; p1++) { for (int l = 0; l<3; l++) { if (p1 == 0) { - color_adjust[p1][l][0] = 1.0; - color_adjust[p1][l][1] = 0.0; - color_adjust[p1][l][2] = 0.0; + color_adjust[p1][l] = 1.0; } else { - for (int k = 0; k<3; k++) { - color_adjust[p1][l][k] = gsl_vector_get(c, var_offset(p1, l, k)); - } + color_adjust[p1][l] = gsl_vector_get(c, var_offset(p1, l)); } } -fprintf(stderr, "==> color_adjust(%d) %f %f %f\n", p1, color_adjust[p1][0][0], color_adjust[p1][1][0],color_adjust[p1][2][0]); +fprintf(stderr, "==> color_adjust(%d) %f %f %f\n", p1, color_adjust[p1][0], color_adjust[p1][1],color_adjust[p1][2]); } return 0; @@ -241,9 +237,9 @@ Stitch::color_correct(uchar c, double a, int pic, int color) { double cd = (double) c; cd = cd * ( - color_adjust[pic][color][0] + - color_adjust[pic][color][1] * a * a + - color_adjust[pic][color][2] * a * a * a * a); + color_adjust[pic][color] + + V1 * a * a + + V2 * a * a * a * a); return (uchar) MIN(rint(cd), 255.0); } -- cgit v1.2.3 From d09316016e4e0b782d784785641fec91de7d58a6 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 16 Mar 2007 18:35:35 +0100 Subject: switch to 16 bit color depth internally --- src/GipfelWidget.H | 8 ++++---- src/GipfelWidget.cxx | 49 ++++++++++++++++++---------------------------- src/JPEGOutputImage.H | 2 +- src/JPEGOutputImage.cxx | 8 ++++---- src/OutputImage.H | 4 ++-- src/OutputImage.cxx | 4 ++-- src/PreviewOutputImage.H | 2 +- src/PreviewOutputImage.cxx | 8 ++++---- src/Stitch.H | 2 +- src/Stitch.cxx | 39 +++++++++++++++++++++--------------- src/TIFFOutputImage.H | 2 +- src/TIFFOutputImage.cxx | 8 ++++---- 12 files changed, 66 insertions(+), 70 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index f5254e7..8cb6d3f 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -39,13 +39,13 @@ class GipfelWidget : public Fl_Widget { int get_rel_track_width(Hill *m); static int get_pixel_nearest(Fl_Image *img, double x, double y, - uchar *r, uchar *g, uchar *b); + int *r, int *g, int *b); static int get_pixel_bilinear(Fl_Image *img, double x, double y, - uchar *r, uchar *g, uchar *b); + int *r, int *g, int *b); static int get_pixel(Fl_Image *img, int x, int y, - uchar *r, uchar *g, uchar *b); + int *r, int *g, int *b); public: typedef enum { @@ -124,7 +124,7 @@ class GipfelWidget : public Fl_Widget { int comp_params(); int get_pixel(GipfelWidget::sample_mode_t, - double a_alph, double a_nick, uchar *r, uchar *g, uchar *b); + double a_alph, double a_nick, int *r, int *g, int *b); double get_angle_off(double view, double nick); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index e88c0cb..1eb8866 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -670,9 +670,9 @@ GipfelWidget::handle(int event) { int GipfelWidget::get_pixel(GipfelWidget::sample_mode_t m, - double a_alph, double a_nick, uchar *r, uchar *g, uchar *b) { + double a_alph, double a_nick, int *r, int *g, int *b) { double px, py; - uchar r_tmp, g_tmp, b_tmp; + int r_tmp, g_tmp, b_tmp; int ret; if (img == NULL) { @@ -691,20 +691,6 @@ GipfelWidget::get_pixel(GipfelWidget::sample_mode_t m, py + ((double) img->h()) / 2.0, r, g, b); } -#if 0 - if (ret == 0) { -fprintf(stderr, "===> %d\n", ret); - double angle = atan(pow(pow(tan(a_alph - pan->parms.a_center), 2.0) + - pow(tan(a_nick - pan->parms.a_nick), 2.0), 0.5)); - double devign = 1.0 / pow(cos(angle), 1.5); - fprintf(stderr, "===> %lf\n", devign); - - *r = (uchar) MIN(rint((double) r_tmp * devign), 255); - *g = (uchar) MIN(rint((double) g_tmp * devign), 255); - *b = (uchar) MIN(rint((double) b_tmp * devign), 255); - } -#endif - return ret; } @@ -718,7 +704,7 @@ GipfelWidget::get_angle_off(double a_alph, double a_nick) { int GipfelWidget::get_pixel_nearest(Fl_Image *img, double x, double y, - uchar *r, uchar *g, uchar *b) { + int *r, int *g, int *b) { if (isnan(x) || isnan(y)) { return 1; } else { @@ -728,10 +714,10 @@ GipfelWidget::get_pixel_nearest(Fl_Image *img, double x, double y, int GipfelWidget::get_pixel_bilinear(Fl_Image *img, double x, double y, - uchar *r, uchar *g, uchar *b) { - uchar a_r[4] = {0, 0, 0, 0}; - uchar a_g[4] = {0, 0, 0, 0}; - uchar a_b[4] = {0, 0, 0, 0}; + int *r, int *g, int *b) { + int a_r[4] = {0, 0, 0, 0}; + int a_g[4] = {0, 0, 0, 0}; + int a_b[4] = {0, 0, 0, 0}; float v0 , v1; int fl_x = (int) floor(x); int fl_y = (int) floor(y); @@ -748,15 +734,15 @@ GipfelWidget::get_pixel_bilinear(Fl_Image *img, double x, double y, v0 = a_r[0] * (1 - (x - fl_x)) + a_r[1] * (x - fl_x); v1 = a_r[2] * (1 - (x - fl_x)) + a_r[3] * (x - fl_x); - *r = (uchar) rint(v0 * (1 - (y - fl_y)) + v1 * (y - fl_y)); + *r = (int) rint(v0 * (1 - (y - fl_y)) + v1 * (y - fl_y)); v0 = a_g[0] * (1 - (x - fl_x)) + a_g[1] * (x - fl_x); v1 = a_g[2] * (1 - (x - fl_x)) + a_g[3] * (x - fl_x); - *g = (uchar) rint(v0 * (1 - (y - fl_y)) + v1 * (y - fl_y)); + *g = (int) rint(v0 * (1 - (y - fl_y)) + v1 * (y - fl_y)); v0 = a_b[0] * (1 - (x - fl_x)) + a_b[1] * (x - fl_x); v1 = a_b[2] * (1 - (x - fl_x)) + a_b[3] * (x - fl_x); - *b = (uchar) rint(v0 * (1 - (y - fl_y)) + v1 * (y - fl_y)); + *b = (int) rint(v0 * (1 - (y - fl_y)) + v1 * (y - fl_y)); if (n >= 1) { return 1; @@ -767,7 +753,7 @@ GipfelWidget::get_pixel_bilinear(Fl_Image *img, double x, double y, int GipfelWidget::get_pixel(Fl_Image *img, int x, int y, - uchar *r, uchar *g, uchar *b) { + int *r, int *g, int *b) { if ( img->d() == 0 ) { return 1; } @@ -779,16 +765,16 @@ GipfelWidget::get_pixel(Fl_Image *img, int x, int y, switch (img->count()) { case 1: { // bitmap - const char *buf = img->data()[0]; + const unsigned char *buf = (const unsigned char*) img->data()[0]; switch (img->d()) { case 1: *r = *g = *b = *(buf+index); break; case 3: // 24bit - *r = *(buf+index+0); - *g = *(buf+index+1); - *b = *(buf+index+2); + *r = (int) *(buf+index+0); + *g = (int) *(buf+index+1); + *b = (int) *(buf+index+2); break; default: // ?? printf("Not supported: chans=%d\n", img->d()); @@ -801,8 +787,11 @@ GipfelWidget::get_pixel(Fl_Image *img, int x, int y, return 1; } - return 0; + *r = *r * 255; + *g = *g * 255; + *b = *b * 255; + return 0; } int diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H index b3554c8..a4b8f47 100644 --- a/src/JPEGOutputImage.H +++ b/src/JPEGOutputImage.H @@ -32,7 +32,7 @@ class JPEGOutputImage : OutputImage { protected: int init_internal(int w, int h); - int set_pixel_internal(int x, char r, char g, char b); + int set_pixel_internal(int x, int r, int g, int b); int next_line_internal(); diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index 6e685d0..bfe4595 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -68,10 +68,10 @@ JPEGOutputImage::init_internal(int w1, int h1) { } int -JPEGOutputImage::set_pixel_internal(int x, char r, char g, char b) { - row[x*3+0] = r; - row[x*3+1] = g; - row[x*3+2] = b; +JPEGOutputImage::set_pixel_internal(int x, int r, int g, int b) { + row[x*3+0] = (unsigned char) r; + row[x*3+1] = (unsigned char) g; + row[x*3+2] = (unsigned char) b; return 0; } diff --git a/src/OutputImage.H b/src/OutputImage.H index 7c9f0fd..17955b9 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -19,7 +19,7 @@ class OutputImage { virtual int init(int w1, int h1); - int set_pixel(int x, char r, char g, char b); + int set_pixel(int x, int r, int g, int b); int next_line(); @@ -30,7 +30,7 @@ class OutputImage { virtual int init_internal(int w1, int h1); - virtual int set_pixel_internal(int x, char r, char g, char b); + virtual int set_pixel_internal(int x, int r, int g, int b); virtual int next_line_internal(); diff --git a/src/OutputImage.cxx b/src/OutputImage.cxx index ddf8e14..f981f18 100644 --- a/src/OutputImage.cxx +++ b/src/OutputImage.cxx @@ -35,7 +35,7 @@ OutputImage::init_internal(int w1, int h1) { } int -OutputImage::set_pixel(int x, char r, char g, char b) { +OutputImage::set_pixel(int x, int r, int g, int b) { if (!initialized || x < 0 || x >= W) { return 1; } else { @@ -44,7 +44,7 @@ OutputImage::set_pixel(int x, char r, char g, char b) { } int -OutputImage::set_pixel_internal(int x, char r, char g, char b) { +OutputImage::set_pixel_internal(int x, int r, int g, int b) { return 0; } diff --git a/src/PreviewOutputImage.H b/src/PreviewOutputImage.H index 8b41684..cbd55a6 100644 --- a/src/PreviewOutputImage.H +++ b/src/PreviewOutputImage.H @@ -29,7 +29,7 @@ class PreviewOutputImage : OutputImage , public Fl_Widget { protected: int init_internal(int w, int h); - int set_pixel_internal(int x, char r, char g, char b); + int set_pixel_internal(int x, int r, int g, int b); int next_line_internal(); diff --git a/src/PreviewOutputImage.cxx b/src/PreviewOutputImage.cxx index 86dadee..0ae182e 100644 --- a/src/PreviewOutputImage.cxx +++ b/src/PreviewOutputImage.cxx @@ -35,15 +35,15 @@ PreviewOutputImage::init_internal(int w, int h) { int -PreviewOutputImage::set_pixel_internal(int x, char r, char g, char b) { +PreviewOutputImage::set_pixel_internal(int x, int r, int g, int b) { if (!data) { return 1; } long index = (line * w() * d + (x * d)); - *(data+index+0) = r; - *(data+index+1) = g; - *(data+index+2) = b; + *(data+index+0) = (unsigned char) (r / 255); + *(data+index+1) = (unsigned char) (g / 255); + *(data+index+2) = (unsigned char) (b / 255); return 0; } diff --git a/src/Stitch.H b/src/Stitch.H index 9fe3c15..b5fb6fd 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -23,7 +23,7 @@ class Stitch { OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; - uchar color_correct(uchar c, double a, int pic, int color); + int color_correct(int c, double a, int pic, int color); public: Stitch(); diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 3876e77..af0df91 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -17,7 +17,7 @@ #include "Stitch.H" #define MIN(A,B) ((A)<(B)?(A):(B)) - +#define MAX_VALUE 65025 static double pi_d = asin(1.0) * 2.0; static double deg2rad = pi_d / 180.0; @@ -99,12 +99,12 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, view_end = view_end * deg2rad; double step_view = (view_end - view_start) / w; - uchar r, g, b; + int r, g, b; int y_off = h / 2; int merged_pixel_set; double radius = (double) w / (view_end -view_start); - int max_samples = 5000 * 3, n_samples = 0; + int max_samples = 50000 * 3, n_samples = 0; int ret; int n_vars = 2 + num_pics * 3 ; gsl_matrix *X, *cov; @@ -129,7 +129,7 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, a_view = view_start + x * step_view; merged_pixel_set = 0; double a1, a2; - uchar c1[3], c2[3]; + int c1[3], c2[3]; double c1d[3], c2d[3]; for (int p1=0; p1get_pixel(m, a_view, a_nick, &c1[0], &c1[1], &c1[2]) == 0) { - for (int l = 0; l<3; l++) { c1d[l] = (double) c1[l]; } @@ -159,12 +158,20 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, a2 = gipf[p2]->get_angle_off(a_view, a_nick); if (n_samples < max_samples && - c1[0] < 200 && c1[1] < 200 && c1[2] < 200 && - c2[0] < 200 && c2[1] < 200 && c2[2] < 200 && - c1[0] > 20 && c1[1] > 20 && c1[2] > 20 && - c2[0] > 20 && c2[1] > 20 && c2[2] > 20 && - fabs(c1d[1] / c1d[0] - c2d[1] / c2d[0]) < 0.02 && - fabs(c1d[2] / c1d[0] - c2d[2] / c2d[0]) < 0.02 ) { + c1[0] < MAX_VALUE * 0.8 && + c1[1] < MAX_VALUE * 0.8 && + c1[2] < MAX_VALUE * 0.8 && + c2[0] < MAX_VALUE * 0.8 && + c2[1] < MAX_VALUE * 0.8 && + c2[2] < MAX_VALUE * 0.8 && + c1[0] > MAX_VALUE * 0.2 && + c1[1] > MAX_VALUE * 0.2 && + c1[2] > MAX_VALUE * 0.2 && + c2[0] > MAX_VALUE * 0.2 && + c2[1] > MAX_VALUE * 0.2 && + c2[2] > MAX_VALUE * 0.2) { +// fabs(c1d[1] / c1d[0] - c2d[1] / c2d[0]) < 0.2 && +// fabs(c1d[2] / c1d[0] - c2d[2] / c2d[0]) < 0.2 ) { for (int l = 0; l<3; l++) { if (p1 == 0) { @@ -186,7 +193,7 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, } if (merged_image) { - merged_image->set_pixel(x, 255, 0, 0); + merged_image->set_pixel(x, 65025, 0, 0); merged_pixel_set++; } } @@ -233,15 +240,15 @@ fprintf(stderr, "==> V1 %f V2 %f\n", V1, V2); return 0; } -uchar -Stitch::color_correct(uchar c, double a, int pic, int color) { +int +Stitch::color_correct(int c, double a, int pic, int color) { double cd = (double) c; cd = cd * (color_adjust[pic][color] + V1 * a * a + V2 * a * a * a * a); - return (uchar) MIN(rint(cd), 255.0); + return (int) MIN(rint(cd), 65025.0); } int @@ -252,7 +259,7 @@ Stitch::resample(GipfelWidget::sample_mode_t m, view_end = view_end * deg2rad; double step_view = (view_end - view_start) / w; - uchar r, g, b; + int r, g, b; int y_off = h / 2; int merged_pixel_set; double radius = (double) w / (view_end -view_start); diff --git a/src/TIFFOutputImage.H b/src/TIFFOutputImage.H index 820a281..ce61462 100644 --- a/src/TIFFOutputImage.H +++ b/src/TIFFOutputImage.H @@ -26,7 +26,7 @@ class TIFFOutputImage : OutputImage { protected: int init_internal(int w, int h); - int set_pixel_internal(int x, char r, char g, char b); + int set_pixel_internal(int x, int r, int g, int b); int next_line_internal(); diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx index 397caac..4034c97 100644 --- a/src/TIFFOutputImage.cxx +++ b/src/TIFFOutputImage.cxx @@ -61,10 +61,10 @@ TIFFOutputImage::init_internal(int w1, int h1) { } int -TIFFOutputImage::set_pixel_internal(int x, char r, char g, char b) { - row[x*4+0] = r; - row[x*4+1] = g; - row[x*4+2] = b; +TIFFOutputImage::set_pixel_internal(int x, int r, int g, int b) { + row[x*4+0] = (unsigned char) r; + row[x*4+1] = (unsigned char) g; + row[x*4+2] = (unsigned char) b; row[x*4+3] = 255; return 0; -- cgit v1.2.3 From ad1abce7a41bdb5f6d2005ac63f6e8b5599ec244 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 18 Mar 2007 12:21:29 +0100 Subject: remove color adjust stuff --- src/Stitch.H | 1 - src/Stitch.cxx | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index b5fb6fd..7a47cf6 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -18,7 +18,6 @@ class Stitch { private: GipfelWidget *gipf[MAX_PICS]; int num_pics; - double color_adjust[MAX_PICS][3]; double V1, V2; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 69d72be..c0a770b 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -220,15 +220,6 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, ret = gsl_multifit_wlinear (X, wv, yv, c, cov, &chisq, work); gsl_multifit_linear_free (work); - fprintf(stderr, "gsl_multifit_linear returned %d\n", ret); - - for (int p1=0; p1 < num_pics; p1++) { - for (int l = 0; l<3; l++) { - color_adjust[p1][l] = 1.0; - } -fprintf(stderr, "==> color_adjust(%d) %f %f %f\n", p1, color_adjust[p1][0], color_adjust[p1][1],color_adjust[p1][2]); - } - V1 = gsl_vector_get(c, 0); V2 = gsl_vector_get(c, 1); fprintf(stderr, "==> V1 %f V2 %f\n", V1, V2); @@ -240,7 +231,7 @@ int Stitch::color_correct(int c, double a, int pic, int color) { double cd = (double) c; - cd = cd * (color_adjust[pic][color] + + cd = cd * (1.0 + V1 * a * a + V2 * a * a * a * a); -- cgit v1.2.3 From 5457c660336a7f9bc74bdf85ab4e001a4f81a6f9 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 19 Mar 2007 18:04:49 +0100 Subject: further refactoring --- src/Stitch.H | 6 ++++++ src/Stitch.cxx | 58 ++++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 20 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index 7a47cf6..b2913aa 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -19,11 +19,17 @@ class Stitch { GipfelWidget *gipf[MAX_PICS]; int num_pics; double V1, V2; + double color_adjust[MAX_PICS][3]; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; + double vignetting_parameter(int pic, double a_view, double a_nick); + int color_correct(int c, double a, int pic, int color); + int get_pixel(GipfelWidget::sample_mode_t m, int pic, + double a_view, double a_nick, int *r, int *g, int *b); + public: Stitch(); diff --git a/src/Stitch.cxx b/src/Stitch.cxx index 47e9667..1da565b 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -27,10 +27,14 @@ Stitch::Stitch() { for (int i=0; iget_angle_off(a_view, a_nick)), 4.0); +} + int Stitch::vignette_calib(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end) { @@ -121,7 +130,6 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, view_end = view_end * deg2rad; double step_view = (view_end - view_start) / w; - int r, g, b; int y_off = h / 2; int merged_pixel_set; double radius = (double) w / (view_end -view_start); @@ -149,45 +157,43 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, double a_view; a_view = view_start + x * step_view; merged_pixel_set = 0; - double a1, a2; int c1[3], c2[3]; double c1d[3], c2d[3]; for (int p1=0; p1get_pixel(m, a_view, a_nick, + } else if (get_pixel(m, p1, a_view, a_nick, &c1[0], &c1[1], &c1[2]) == 0) { + for (int l = 0; l<3; l++) { c1d[l] = (double) c1[l]; } - a1 = gipf[p1]->get_angle_off(a_view, a_nick); + double a1 = vignetting_parameter(p1, a_view, a_nick); + + for (int p2 = p1 + 1; p2 < num_pics; p2++) { - for (int p2=0; p2get_pixel(m, a_view, a_nick, + if (get_pixel(m, p2, a_view, a_nick, &c2[0], &c2[1], &c2[2]) == 0) { for (int l = 0; l<3; l++) { c2d[l] = (double) c2[l]; } - a2 = pow(cos(gipf[p2]->get_angle_off(a_view, a_nick)), 4.0); if (n_samples < max_samples && similar_color(c1d, c2d)) { + double a2 = vignetting_parameter(p2, a_view, a_nick); + for (int l = 0; l<3; l++) { gsl_matrix_set(X, n_samples, 0, c1d[l] * a1); gsl_matrix_set(X, n_samples, 1, c1d[l] * a1 * a1); gsl_matrix_set(X, n_samples, 0, -c2d[l] * a2); gsl_matrix_set(X, n_samples, 1, -c2d[l] * a2 * a2); - gsl_vector_set(yv, n_samples, c2d[l]-c1d[l]); + gsl_vector_set(yv, n_samples, c2d[l] - c1d[l]); n_samples++; } @@ -234,11 +240,28 @@ int Stitch::color_correct(int c, double a, int pic, int color) { double cd = (double) c; - cd = cd * (1.0 + V1 * a + V2 * a * a); + cd = cd * color_adjust[pic][color] * (1.0 + V1 * a + V2 * a * a); return MAX(MIN((int) rint(cd), 65025), 0); } +int +Stitch::get_pixel(GipfelWidget::sample_mode_t m, int pic, + double a_view, double a_nick, int *r, int *g, int *b) { + + if (gipf[pic]->get_pixel(m, a_view, a_nick, r, g, b) != 0) { + return 1; + } + + double a = vignetting_parameter(pic, a_view, a_nick); + + *r = color_correct(*r, a, pic, 0); + *g = color_correct(*g, a, pic, 1); + *b = color_correct(*b, a, pic, 2); + + return 0; +} + int Stitch::resample(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end) { @@ -272,13 +295,8 @@ Stitch::resample(GipfelWidget::sample_mode_t m, for (int i=0; iget_pixel(m, a_view, a_nick, + } else if (get_pixel(m, i, a_view, a_nick, &r, &g, &b) == 0) { - double a = pow(cos(gipf[i]->get_angle_off(a_view, a_nick)), 4.0); - - r = color_correct(r, a, i, 0); - g = color_correct(g, a, i, 1); - b = color_correct(b, a, i, 2); if (single_images[i]) { single_images[i]->set_pixel(x, r, g, b); -- cgit v1.2.3 From eb4b8da95067a71e727571a5da2bede913690dd0 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 19 Mar 2007 18:52:45 +0100 Subject: implement color correction --- src/Stitch.H | 3 ++ src/Stitch.cxx | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/gipfel.cxx | 1 + 3 files changed, 128 insertions(+), 4 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index b2913aa..cd8d7d4 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -46,6 +46,9 @@ class Stitch { int vignette_calib(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end); + + int color_calib(GipfelWidget::sample_mode_t m, + int w, int h, double view_start, double view_end); }; #endif diff --git a/src/Stitch.cxx b/src/Stitch.cxx index c099a72..a6c54ce 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -92,10 +92,6 @@ Stitch::set_output(const char *file, OutputImage *img) { return ret; } -static int -var_offset(int pic, int color) { - return 2 + pic* 3 + color; -} static int similar_color(double *c1, double *c2) { @@ -115,6 +111,130 @@ similar_color(double *c1, double *c2) { } } +static int +var_offset(int pic, int color) { + return (pic - 1) * 3 + color; +} + +int +Stitch::color_calib(GipfelWidget::sample_mode_t m, + int w, int h, double view_start, double view_end) { + + w = 1500; + h = 400; + + view_start = view_start * deg2rad; + view_end = view_end * deg2rad; + + double step_view = (view_end - view_start) / w; + int y_off = h / 2; + int merged_pixel_set; + double radius = (double) w / (view_end -view_start); + + int max_samples = 20000 * 3, n_samples = 0; + int ret; + int n_vars = (num_pics - 1) * 3; + gsl_matrix *X, *cov; + gsl_vector *yv, *c; + double chisq; + + X = gsl_matrix_calloc(max_samples, n_vars); + yv = gsl_vector_calloc(max_samples); + c = gsl_vector_calloc(n_vars); + cov = gsl_matrix_calloc (n_vars, n_vars); + + if (merged_image) { + merged_image->init(w, h); + } + + for (int y = 0; y < h; y++) { + double a_nick = atan((double)(y_off - y)/radius); + + for (int x = 0; x < w; x++) { + double a_view; + a_view = view_start + x * step_view; + merged_pixel_set = 0; + int c1[3], c2[3]; + double c1d[3], c2d[3]; + + for (int p1 = 0; p1 < num_pics; p1++) { + if (get_pixel(m, p1, a_view, a_nick, + &c1[0], &c1[1], &c1[2]) == 0) { + + for (int l = 0; l<3; l++) { + c1d[l] = (double) c1[l]; + } + + for (int p2 = p1 + 1; p2 < num_pics; p2++) { + + if (get_pixel(m, p2, a_view, a_nick, + &c2[0], &c2[1], &c2[2]) == 0) { + + for (int l = 0; l<3; l++) { + c2d[l] = (double) c2[l]; + } + + + if (n_samples < max_samples && + similar_color(c1d, c2d)) { + + for (int l = 0; l<3; l++) { + if (p1 == 0) { + gsl_matrix_set(X, n_samples, var_offset(p2, l), c2d[l]); + + gsl_vector_set(yv, n_samples, c1d[l]); + } else { + gsl_matrix_set(X, n_samples, var_offset(p1, l), c1d[l]); + gsl_matrix_set(X, n_samples, var_offset(p2, l), -c2d[l]); + + gsl_vector_set(yv, n_samples, 0.0); + } + n_samples++; + } + + if (merged_image) { + merged_image->set_pixel(x, 0, 0, 65025); + merged_pixel_set++; + } + } + + } + } + + if (!merged_pixel_set && merged_image) { + merged_image->set_pixel(x, c1[0], c1[1], c1[2]); + merged_pixel_set++; + } + + } + } + } + if (merged_image) { + merged_image->next_line(); + } + } + + if (merged_image) { + merged_image->done(); + } + + gsl_multifit_linear_workspace * work + = gsl_multifit_linear_alloc (max_samples, n_vars); + + ret = gsl_multifit_linear (X, yv, c, cov, &chisq, work); + gsl_multifit_linear_free (work); + + for (int i = 1; i < num_pics; i++) { + for (int l = 0; l<3; l++) { + color_adjust[i][l] = gsl_vector_get(c, var_offset(i, l)); + } + + fprintf(stderr, "color_adjust(%d) %f\n", i, color_adjust[i][0]); + } + + return 0; +} + double Stitch::vignetting_parameter(int pic, double a_view, double a_nick) { return pow(cos(gipf[pic]->get_angle_off(a_view, a_nick)), 4.0); diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 8ef6b22..9653ae1 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -579,6 +579,7 @@ stitch(GipfelWidget::sample_mode_t m, win->show(0, argv); st->set_output((OutputImage*) img); st->vignette_calib(m, stitch_w, stitch_h, from, to); + // st->color_calib(m, stitch_w, stitch_h, from, to); } if (type & STITCH_JPEG) { -- cgit v1.2.3 From 429ccd9cd43376eab85f84d30427d0d4fb3fa405 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 20 Mar 2007 23:26:23 +0100 Subject: use single variable vignetting correction model --- src/Stitch.H | 2 +- src/Stitch.cxx | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index cd8d7d4..636991c 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -18,7 +18,7 @@ class Stitch { private: GipfelWidget *gipf[MAX_PICS]; int num_pics; - double V1, V2; + double V[4]; double color_adjust[MAX_PICS][3]; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; diff --git a/src/Stitch.cxx b/src/Stitch.cxx index f0f7236..d59fc87 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -34,8 +34,10 @@ Stitch::Stitch() { merged_image = NULL; num_pics = 0; - V1 = 0.0; - V2 = 0.0; + V[0] = 0.0; + V[1] = 0.0; + V[2] = 0.0; + V[3] = 0.0; } Stitch::~Stitch() { @@ -237,7 +239,7 @@ Stitch::color_calib(GipfelWidget::sample_mode_t m, double Stitch::vignetting_parameter(int pic, double a_view, double a_nick) { - return pow(cos(gipf[pic]->get_angle_off(a_view, a_nick)), 4.0); + return 1.0/pow(cos(gipf[pic]->get_angle_off(a_view, a_nick)), 4.0); } int @@ -257,7 +259,7 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, int max_samples = 20000 * 3, n_samples = 0; int ret; - int n_vars = 2; + int n_vars = 1; gsl_matrix *X, *cov; gsl_vector *yv, *c; double chisq; @@ -307,10 +309,7 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, double a2 = vignetting_parameter(p2, a_view, a_nick); for (int l = 0; l<3; l++) { - gsl_matrix_set(X, n_samples, 0, c1d[l] * a1); - gsl_matrix_set(X, n_samples, 1, c1d[l] * a1 * a1); - gsl_matrix_set(X, n_samples, 0, -c2d[l] * a2); - gsl_matrix_set(X, n_samples, 1, -c2d[l] * a2 * a2); + gsl_matrix_set(X, n_samples, 0, a1 * c1d[l] - a2 * c2d[l]); gsl_vector_set(yv, n_samples, c2d[l] - c1d[l]); n_samples++; @@ -348,18 +347,19 @@ Stitch::vignette_calib(GipfelWidget::sample_mode_t m, ret = gsl_multifit_linear (X, yv, c, cov, &chisq, work); gsl_multifit_linear_free (work); - V1 = gsl_vector_get(c, 0); - V2 = gsl_vector_get(c, 1); - fprintf(stderr, "==> V1 %f V2 %f\n", V1, V2); - + for (int i=0; i < n_vars; i++) { + V[i] = gsl_vector_get(c, i); + fprintf(stderr, "==> V[i] %f\n", V[i]); + } + return 0; } int Stitch::color_correct(int c, double a, int pic, int color) { double cd = (double) c; - - cd = cd * color_adjust[pic][color] * (1.0 + V1 * a + V2 * a * a); + + cd = cd * color_adjust[pic][color] * a; return MAX(MIN((int) rint(cd), 65025), 0); } -- cgit v1.2.3 From 5b4a674c5922c6516ce6fe580800bacb5bf18b91 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 9 May 2007 18:49:32 +0200 Subject: remove color- and vignetting correction code --- src/Stitch.H | 15 --- src/Stitch.cxx | 296 +-------------------------------------------------------- src/gipfel.cxx | 24 +---- 3 files changed, 3 insertions(+), 332 deletions(-) (limited to 'src/Stitch.H') diff --git a/src/Stitch.H b/src/Stitch.H index 636991c..0632192 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -18,18 +18,9 @@ class Stitch { private: GipfelWidget *gipf[MAX_PICS]; int num_pics; - double V[4]; - double color_adjust[MAX_PICS][3]; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; - double vignetting_parameter(int pic, double a_view, double a_nick); - - int color_correct(int c, double a, int pic, int color); - - int get_pixel(GipfelWidget::sample_mode_t m, int pic, - double a_view, double a_nick, int *r, int *g, int *b); - public: Stitch(); @@ -43,12 +34,6 @@ class Stitch { int resample(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end); - - int vignette_calib(GipfelWidget::sample_mode_t m, - int w, int h, double view_start, double view_end); - - int color_calib(GipfelWidget::sample_mode_t m, - int w, int h, double view_start, double view_end); }; #endif diff --git a/src/Stitch.cxx b/src/Stitch.cxx index d59fc87..49d2c77 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -27,17 +27,10 @@ Stitch::Stitch() { for (int i=0; i MAX_VALUE * 0.9 || c1[i] < MAX_VALUE * 0.1 || - c2[i] > MAX_VALUE * 0.9 || c2[i] < MAX_VALUE * 0.1) { - return 0; - } - } - - if (fabs(c1[1] / c1[0] - c2[1] / c2[0]) < 0.05 && - fabs(c1[1] / c1[2] - c2[1] / c2[2]) < 0.05 && - fabs(c1[2] / c1[0] - c2[2] / c2[0]) < 0.05 ) { - return 1; - } else { - return 0; - } -} - -static int -var_offset(int pic, int color) { - return (pic - 1) * 3 + color; -} - -int -Stitch::color_calib(GipfelWidget::sample_mode_t m, - int w, int h, double view_start, double view_end) { - - w = 1500; - h = 400; - - view_start = view_start * deg2rad; - view_end = view_end * deg2rad; - - double step_view = (view_end - view_start) / w; - int y_off = h / 2; - int merged_pixel_set; - double radius = (double) w / (view_end -view_start); - - int max_samples = 20000 * 3, n_samples = 0; - int ret; - int n_vars = (num_pics - 1) * 3; - gsl_matrix *X, *cov; - gsl_vector *yv, *c; - double chisq; - - X = gsl_matrix_calloc(max_samples, n_vars); - yv = gsl_vector_calloc(max_samples); - c = gsl_vector_calloc(n_vars); - cov = gsl_matrix_calloc (n_vars, n_vars); - - if (merged_image) { - merged_image->init(w, h); - } - - for (int y = 0; y < h; y++) { - double a_nick = atan((double)(y_off - y)/radius); - - for (int x = 0; x < w; x++) { - double a_view; - a_view = view_start + x * step_view; - merged_pixel_set = 0; - int c1[3], c2[3]; - double c1d[3], c2d[3]; - - for (int p1 = 0; p1 < num_pics; p1++) { - if (get_pixel(m, p1, a_view, a_nick, - &c1[0], &c1[1], &c1[2]) == 0) { - - for (int l = 0; l<3; l++) { - c1d[l] = (double) c1[l]; - } - - for (int p2 = p1 + 1; p2 < num_pics; p2++) { - - if (get_pixel(m, p2, a_view, a_nick, - &c2[0], &c2[1], &c2[2]) == 0) { - - for (int l = 0; l<3; l++) { - c2d[l] = (double) c2[l]; - } - - - if (n_samples < max_samples && - similar_color(c1d, c2d)) { - - for (int l = 0; l<3; l++) { - if (p1 == 0) { - gsl_matrix_set(X, n_samples, var_offset(p2, l), c2d[l]); - - gsl_vector_set(yv, n_samples, c1d[l]); - } else { - gsl_matrix_set(X, n_samples, var_offset(p1, l), c1d[l]); - gsl_matrix_set(X, n_samples, var_offset(p2, l), -c2d[l]); - - gsl_vector_set(yv, n_samples, 0.0); - } - n_samples++; - } - - if (merged_image) { - merged_image->set_pixel(x, 0, 0, 65025); - merged_pixel_set++; - } - } - - } - } - - if (!merged_pixel_set && merged_image) { - merged_image->set_pixel(x, c1[0], c1[1], c1[2]); - merged_pixel_set++; - } - - } - } - } - if (merged_image) { - merged_image->next_line(); - } - } - - if (merged_image) { - merged_image->done(); - } - - gsl_multifit_linear_workspace * work - = gsl_multifit_linear_alloc (max_samples, n_vars); - - ret = gsl_multifit_linear (X, yv, c, cov, &chisq, work); - gsl_multifit_linear_free (work); - - for (int i = 1; i < num_pics; i++) { - for (int l = 0; l<3; l++) { - color_adjust[i][l] = gsl_vector_get(c, var_offset(i, l)); - } - - fprintf(stderr, "color_adjust(%d) %f\n", i, color_adjust[i][0]); - } - - return 0; -} - -double -Stitch::vignetting_parameter(int pic, double a_view, double a_nick) { - return 1.0/pow(cos(gipf[pic]->get_angle_off(a_view, a_nick)), 4.0); -} - -int -Stitch::vignette_calib(GipfelWidget::sample_mode_t m, - int w, int h, double view_start, double view_end) { - - w = 1500; - h = 400; - - view_start = view_start * deg2rad; - view_end = view_end * deg2rad; - - double step_view = (view_end - view_start) / w; - int y_off = h / 2; - int merged_pixel_set; - double radius = (double) w / (view_end -view_start); - - int max_samples = 20000 * 3, n_samples = 0; - int ret; - int n_vars = 1; - gsl_matrix *X, *cov; - gsl_vector *yv, *c; - double chisq; - - X = gsl_matrix_calloc(max_samples, n_vars); - yv = gsl_vector_calloc(max_samples); - c = gsl_vector_calloc(n_vars); - cov = gsl_matrix_calloc (n_vars, n_vars); - - if (merged_image) { - merged_image->init(w, h); - } - - for (int y = 0; y < h; y++) { - double a_nick = atan((double)(y_off - y)/radius); - - for (int x = 0; x < w; x++) { - double a_view; - a_view = view_start + x * step_view; - merged_pixel_set = 0; - int c1[3], c2[3]; - double c1d[3], c2d[3]; - - for (int p1 = 0; p1 < num_pics; p1++) { - if (get_pixel(m, p1, a_view, a_nick, - &c1[0], &c1[1], &c1[2]) == 0) { - - for (int l = 0; l<3; l++) { - c1d[l] = (double) c1[l]; - } - - double a1 = vignetting_parameter(p1, a_view, a_nick); - - for (int p2 = p1 + 1; p2 < num_pics; p2++) { - - if (get_pixel(m, p2, a_view, a_nick, - &c2[0], &c2[1], &c2[2]) == 0) { - - for (int l = 0; l<3; l++) { - c2d[l] = (double) c2[l]; - } - - - if (n_samples < max_samples && - similar_color(c1d, c2d)) { - - double a2 = vignetting_parameter(p2, a_view, a_nick); - - for (int l = 0; l<3; l++) { - gsl_matrix_set(X, n_samples, 0, a1 * c1d[l] - a2 * c2d[l]); - - gsl_vector_set(yv, n_samples, c2d[l] - c1d[l]); - n_samples++; - } - - if (merged_image) { - merged_image->set_pixel(x, 65025, 0, 0); - merged_pixel_set++; - } - } - - } - } - - if (!merged_pixel_set && merged_image) { - merged_image->set_pixel(x, c1[0], c1[1], c1[2]); - merged_pixel_set++; - } - - } - } - } - if (merged_image) { - merged_image->next_line(); - } - } - - if (merged_image) { - merged_image->done(); - } - - gsl_multifit_linear_workspace * work - = gsl_multifit_linear_alloc (max_samples, n_vars); - - ret = gsl_multifit_linear (X, yv, c, cov, &chisq, work); - gsl_multifit_linear_free (work); - - for (int i=0; i < n_vars; i++) { - V[i] = gsl_vector_get(c, i); - fprintf(stderr, "==> V[i] %f\n", V[i]); - } - - return 0; -} - -int -Stitch::color_correct(int c, double a, int pic, int color) { - double cd = (double) c; - - cd = cd * color_adjust[pic][color] * a; - - return MAX(MIN((int) rint(cd), 65025), 0); -} - -int -Stitch::get_pixel(GipfelWidget::sample_mode_t m, int pic, - double a_view, double a_nick, int *r, int *g, int *b) { - - if (gipf[pic]->get_pixel(m, a_view, a_nick, r, g, b) != 0) { - return 1; - } - - double a = vignetting_parameter(pic, a_view, a_nick); - - *r = color_correct(*r, a, pic, 0); - *g = color_correct(*g, a, pic, 1); - *b = color_correct(*b, a, pic, 2); - - return 0; -} - int Stitch::resample(GipfelWidget::sample_mode_t m, int w, int h, double view_start, double view_end) { @@ -413,7 +119,7 @@ Stitch::resample(GipfelWidget::sample_mode_t m, a_view = view_start + x * step_view; merged_pixel_set = 0; for (int i = 0; i < num_pics; i++) { - if (get_pixel(m, i, a_view, a_nick, + if (gipf[i]->get_pixel(m, a_view, a_nick, &r, &g, &b) == 0) { if (single_images[i]) { diff --git a/src/gipfel.cxx b/src/gipfel.cxx index db13287..9db0fce 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -53,7 +53,6 @@ Fl_Menu_Bar *mb; #define STITCH_PREVIEW 1 #define STITCH_JPEG 2 #define STITCH_TIFF 4 -#define STITCH_VIGNETTE_CALIB 8 static int stitch(GipfelWidget::sample_mode_t m ,int stitch_w, int stitch_h, double from, double to, int type, const char *path, int argc, char **argv); @@ -398,7 +397,7 @@ 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 bicubic_flag = 0, vignette_flag = 0; + int bicubic_flag = 0; double stitch_from = 0.0, stitch_to = 380.0; double dist_k0 = 0.0, dist_k1 = 0.0, dist_x0 = 0.0; char *outpath = "/tmp"; @@ -406,7 +405,7 @@ int main(int argc, char** argv) { err = 0; - while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:V")) != EOF) { + while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:")) != EOF) { switch (c) { case '?': usage(); @@ -421,9 +420,6 @@ int main(int argc, char** argv) { case 's': stitch_flag++; break; - case 'V': - vignette_flag++; - break; case 'r': stitch_flag++; if (optarg && strcmp(optarg, ":")) { @@ -493,10 +489,6 @@ int main(int argc, char** argv) { type = STITCH_PREVIEW; } - if (vignette_flag) { - type |= STITCH_VIGNETTE_CALIB; - } - stitch(bicubic_flag?GipfelWidget::BICUBIC:GipfelWidget::NEAREST, stitch_w, stitch_h, stitch_from, stitch_to, type, outpath, my_argc, my_argv); @@ -569,18 +561,6 @@ stitch(GipfelWidget::sample_mode_t m, } - if (type & STITCH_VIGNETTE_CALIB) { - win = new Fl_Window(0,0, 1000, 400); - scroll = new Fl_Scroll(0, 0, win->w(), win->h()); - PreviewOutputImage *img = - new PreviewOutputImage(0, 0, 1000, 400); - - win->resizable(scroll); - win->show(0, argv); - st->set_output((OutputImage*) img); - st->vignette_calib(m, stitch_w, stitch_h, from, to); - //st->color_calib(m, stitch_w, stitch_h, from, to); - } if (type & STITCH_JPEG) { st->set_output((OutputImage*) new JPEGOutputImage(path, 90)); -- cgit v1.2.3