summaryrefslogtreecommitdiff
path: root/src/Stitch.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-03-16 17:13:56 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-03-16 17:13:56 +0100
commit8cba58d9aa6b4f92fe90231966f58ad0435f1d3f (patch)
treed6f86fda2a35f1dace0b5a58c322b544a435cb0e /src/Stitch.cxx
parentbe9c6d740796edbb097b56ca3fdb181687d5dd47 (diff)
try other model
Diffstat (limited to 'src/Stitch.cxx')
-rw-r--r--src/Stitch.cxx50
1 files changed, 23 insertions, 27 deletions
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);
}