summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Stitch.H3
-rw-r--r--src/Stitch.cxx50
2 files changed, 25 insertions, 28 deletions
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);
}