summaryrefslogtreecommitdiff
path: root/src/Stitch.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Stitch.cxx')
-rw-r--r--src/Stitch.cxx32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/Stitch.cxx b/src/Stitch.cxx
index f21c140..0038b28 100644
--- a/src/Stitch.cxx
+++ b/src/Stitch.cxx
@@ -1,5 +1,5 @@
//
-// Copyright 2006 Johannes Hofmann <Johannes.Hofmann@gmx.de>
+// Copyright 2007 Johannes Hofmann <Johannes.Hofmann@gmx.de>
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
@@ -9,11 +9,17 @@
#include <string.h>
#include <math.h>
+#include <gsl/gsl_multifit.h>
+
#include <Fl/Fl.H>
#include "OutputImage.H"
#include "Stitch.H"
+#define MIN(A,B) ((A)<(B)?(A):(B))
+#define MAX(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;
@@ -22,7 +28,9 @@ Stitch::Stitch() {
gipf[i] = NULL;
single_images[i] = NULL;
}
+
merged_image = NULL;
+ num_pics = 0;
}
Stitch::~Stitch() {
@@ -44,6 +52,8 @@ Stitch::load_image(char *file) {
if (gipf[i]->load_image(file) != 0) {
delete gipf[i];
gipf[i] = NULL;
+ } else {
+ num_pics++;
}
break;
}
@@ -85,7 +95,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);
@@ -93,24 +103,29 @@ Stitch::resample(GipfelWidget::sample_mode_t m,
if (merged_image) {
merged_image->init(w, h);
}
+
for (int i=0; i<MAX_PICS; i++) {
if (single_images[i]) {
single_images[i]->init(w, h);
}
}
- for (int y=0; y<h; y++) {
+ for (int y = 0; y < h; y++) {
double a_nick = atan((double)(y_off - y)/radius);
+ double a_max = 0.0;
- for (int x=0; x<w; x++) {
+ for (int x = 0; x < w; x++) {
double a_view;
a_view = view_start + x * step_view;
merged_pixel_set = 0;
- for (int i=0; i<MAX_PICS; i++) {
- if (gipf[i] == NULL) {
- break;
- } else if (gipf[i]->get_pixel(m, a_view, a_nick,
+ for (int i = 0; i < num_pics; i++) {
+ if (gipf[i]->get_pixel(m, a_view, a_nick,
&r, &g, &b) == 0) {
+
+ r = MAX(MIN(r, MAX_VALUE), 0);
+ g = MAX(MIN(g, MAX_VALUE), 0);
+ b = MAX(MIN(b, MAX_VALUE), 0);
+
if (single_images[i]) {
single_images[i]->set_pixel(x, r, g, b);
}
@@ -142,3 +157,4 @@ Stitch::resample(GipfelWidget::sample_mode_t m,
return 0;
}
+