From bc36079638b4ff3d0b7b3476dc5125bb1fc38c91 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 2 May 2008 15:48:58 +0200 Subject: fix rectilinear projection --- src/lsq_rectilinear.mac | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index 5bd7ac9..d1abf4e 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -2,8 +2,11 @@ * rectilinear (pinhole) projection model with distortion correction */ -x : tan(m_view - c_view)$ -y : tan(c_nick - m_nick)$ +a_v : m_view - c_view$ +a_h : c_nick - atan (tan (m_nick) / cos(a_v))$ + +x : tan(a_v)$ +y : tan(a_h)$ x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ d : x_rot ^ 2 + y_rot ^ 2$ -- cgit v1.2.3 From e322fa254f4b6d22ae7524ba5616dec6d76aa0f2 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 2 May 2008 20:50:30 +0200 Subject: prepare 0.2.3 --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index f38cf52..383500a 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ gipfel ChangeLog ================= +gipfel-0.2.3 + - Fix a major shprtcoming in the rectilinear projection + code. This improves accuracy quite a bit mostly in + wideangle images. + gipfel-0.2.2 - Fix a segfault if exif tool is not installed. - Some optimizations. diff --git a/configure.ac b/configure.ac index 02c0479..b5b9208 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(gipfel, 0.2.2, Johannes.Hofmann@gmx.de) +AC_INIT(gipfel, 0.2.3, Johannes.Hofmann@gmx.de) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([src/Panorama.H]) AC_CONFIG_HEADER(config.h) -- cgit v1.2.3 From d34bb114fe2e3133a0541b0812eed5e146313730 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 2 May 2008 20:52:28 +0200 Subject: typo --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 383500a..f238bff 100644 --- a/NEWS +++ b/NEWS @@ -2,8 +2,8 @@ gipfel ChangeLog ================= gipfel-0.2.3 - - Fix a major shprtcoming in the rectilinear projection - code. This improves accuracy quite a bit mostly in + - Fix a major shortcoming in the rectilinear projection + code. This improves accuracy quite a bit, mostly in wideangle images. gipfel-0.2.2 -- cgit v1.2.3 From d9c027bb9b4bfb74c41c334fc8cf889d4e244b55 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 18 May 2008 19:26:16 +0200 Subject: further rectiliear projection correction --- src/GipfelWidget.cxx | 1 + src/lsq_rectilinear.mac | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 63e89d2..881eb27 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -677,6 +677,7 @@ GipfelWidget::handle(int event) { break; case FL_DRAG: set_mountain(Fl::event_x()-x(), Fl::event_y()-y()); + comp_params(); return 1; break; case FL_RELEASE: diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index d1abf4e..a06670d 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -2,11 +2,14 @@ * rectilinear (pinhole) projection model with distortion correction */ -a_v : m_view - c_view$ -a_h : c_nick - atan (tan (m_nick) / cos(a_v))$ +/* angle over horizon in view direction */ +a_h : atan (tan (m_nick) / cos(m_view - c_view))$ + +/* adjust angle according to nick value */ +a_v : atan(cos(c_nick + a_h) * tan(m_view - c_view) / cos(a_h))$ x : tan(a_v)$ -y : tan(a_h)$ +y : tan(c_nick - a_h)$ x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ d : x_rot ^ 2 + y_rot ^ 2$ -- cgit v1.2.3 From 7669bc038012eb92bd8d3ae842b236cd406ed074 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 21 May 2008 19:47:10 +0200 Subject: rotate in cartesian coordinates --- src/ProjectionLSQ.H | 1 + src/ProjectionLSQ.cxx | 10 +++++----- src/Stitch.cxx | 2 +- src/lsq_rectilinear.mac | 29 ++++++++++++++++++++++++++--- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/ProjectionLSQ.H b/src/ProjectionLSQ.H index 44cc91d..d937114 100644 --- a/src/ProjectionLSQ.H +++ b/src/ProjectionLSQ.H @@ -17,6 +17,7 @@ class ProjectionLSQ { int lsq(const Hills *m, ViewParams *parms, int distortion_correct); protected: + static double pi; double sec(double a); public: diff --git a/src/ProjectionLSQ.cxx b/src/ProjectionLSQ.cxx index cdf9f04..461f36e 100644 --- a/src/ProjectionLSQ.cxx +++ b/src/ProjectionLSQ.cxx @@ -17,7 +17,7 @@ #include "ProjectionLSQ.H" -static double pi_d = asin(1.0) * 2.0; +double ProjectionLSQ::pi = asin(1.0) * 2.0; ProjectionLSQ::ProjectionLSQ() { } @@ -238,10 +238,10 @@ ProjectionLSQ::get_coordinates(double alph, double a_nick, const ViewParams *parms, double *x, double *y) { // Normalize alph - parms->a_center to [-pi/2, pi/2] - if (alph - parms->a_center > pi_d) { - alph -= 2.0 * pi_d; - } else if (alph - parms->a_center < -pi_d) { - alph += 2.0 * pi_d; + if (alph - parms->a_center > pi) { + alph -= 2.0 * pi; + } else if (alph - parms->a_center < -pi) { + alph += 2.0 * pi; } *x = mac_x(parms->a_center, parms->a_nick, parms->a_tilt, parms->scale, diff --git a/src/Stitch.cxx b/src/Stitch.cxx index e4f3d60..aa3798b 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -109,7 +109,7 @@ Stitch::resample(GipfelWidget::sample_mode_t m, } for (int y = 0; y < h; y++) { - double a_nick = atan((double)(y_off - y)/radius); + double a_nick = (double)20.0 - y * step_view; for (int x = 0; x < w; x++) { double a_view; diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index a06670d..e439d09 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -2,14 +2,37 @@ * rectilinear (pinhole) projection model with distortion correction */ +c_x : cos(m_nick) * cos(m_view-c_view)$ +c_y : cos(m_nick) * sin(m_view-c_view)$ +c_z : sin(m_nick)$ + +/* +c_x_rot1 : cos(c_view) * c_x - sin(c_view) * c_y$ +c_y_rot1 : sin(c_view) * c_x + cos(c_view) * c_y$ +c_z_rot1 : c_z$ + +c_x_rot2 : c_x_rot1$ +c_y_rot2 : cos(c_nick) * c_y_rot1 - sin(c_nick) * c_z_rot1$ +c_z_rot2 : sin(c_nick) * c_y_rot1 - cos(c_nick) * c_z_rot1$ + +c_x_rot2 : cos(c_nick) * c_x_rot1$ + sin(c_nick) * c_z_rot1$ +c_y_rot2 : c_y_rot1$ +c_z_rot2 : -sin(c_nick) * c_x_rot1 + cos(c_nick) * c_z_rot1$ +*/ + +a_h : c_nick - (\pi/2 - acos(c_z))$ +a_v : atan(c_y / c_x)$ + + /* angle over horizon in view direction */ -a_h : atan (tan (m_nick) / cos(m_view - c_view))$ +/* a_h : atan (tan (m_nick) * sqrt(tan(m_view - c_view) ^2 + 1))$ */ /* adjust angle according to nick value */ -a_v : atan(cos(c_nick + a_h) * tan(m_view - c_view) / cos(a_h))$ +/* a_v : atan(cos(c_nick - a_h ) * tan((m_view - c_view) / cos(a_h)))$ */ +/* a_v : m_view - c_view$ */ x : tan(a_v)$ -y : tan(c_nick - a_h)$ +y : tan(a_h)$ x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ d : x_rot ^ 2 + y_rot ^ 2$ -- cgit v1.2.3 From 4f544f1ab0d04a4b18fac5e9bec0e869b981f038 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 21 May 2008 19:58:47 +0200 Subject: fixes to cartesian rotation --- src/Stitch.cxx | 2 +- src/lsq_rectilinear.mac | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Stitch.cxx b/src/Stitch.cxx index aa3798b..e4f3d60 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -109,7 +109,7 @@ Stitch::resample(GipfelWidget::sample_mode_t m, } for (int y = 0; y < h; y++) { - double a_nick = (double)20.0 - y * step_view; + double a_nick = atan((double)(y_off - y)/radius); for (int x = 0; x < w; x++) { double a_view; diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index e439d09..bd0a4f9 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -14,25 +14,25 @@ c_z_rot1 : c_z$ c_x_rot2 : c_x_rot1$ c_y_rot2 : cos(c_nick) * c_y_rot1 - sin(c_nick) * c_z_rot1$ c_z_rot2 : sin(c_nick) * c_y_rot1 - cos(c_nick) * c_z_rot1$ - -c_x_rot2 : cos(c_nick) * c_x_rot1$ + sin(c_nick) * c_z_rot1$ -c_y_rot2 : c_y_rot1$ -c_z_rot2 : -sin(c_nick) * c_x_rot1 + cos(c_nick) * c_z_rot1$ */ -a_h : c_nick - (\pi/2 - acos(c_z))$ -a_v : atan(c_y / c_x)$ +c_x_rot : cos(c_nick) * c_x$ + sin(c_nick) * c_z$ +c_y_rot : c_y$ +c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ + +a_h : (\pi/2 - acos(c_z_rot))$ +a_v : atan(c_y_rot / c_x_rot)$ /* angle over horizon in view direction */ -/* a_h : atan (tan (m_nick) * sqrt(tan(m_view - c_view) ^2 + 1))$ */ +a_h_dir : atan (tan (a_h) * sqrt(tan(a_v) ^2 + 1))$ /* adjust angle according to nick value */ /* a_v : atan(cos(c_nick - a_h ) * tan((m_view - c_view) / cos(a_h)))$ */ /* a_v : m_view - c_view$ */ x : tan(a_v)$ -y : tan(a_h)$ +y : tan(-a_h_dir)$ x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ d : x_rot ^ 2 + y_rot ^ 2$ -- cgit v1.2.3 From d98e0c7977a5872bf3f32926b75ef7df14090b7e Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 21 May 2008 20:35:29 +0200 Subject: add comments --- src/lsq_rectilinear.mac | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index bd0a4f9..cea35e1 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -2,39 +2,28 @@ * rectilinear (pinhole) projection model with distortion correction */ -c_x : cos(m_nick) * cos(m_view-c_view)$ -c_y : cos(m_nick) * sin(m_view-c_view)$ +/* switch to cartesian coordinates for nick rotation */ +c_x : cos(m_nick) * cos(m_view - c_view)$ +c_y : cos(m_nick) * sin(m_view - c_view)$ c_z : sin(m_nick)$ -/* -c_x_rot1 : cos(c_view) * c_x - sin(c_view) * c_y$ -c_y_rot1 : sin(c_view) * c_x + cos(c_view) * c_y$ -c_z_rot1 : c_z$ - -c_x_rot2 : c_x_rot1$ -c_y_rot2 : cos(c_nick) * c_y_rot1 - sin(c_nick) * c_z_rot1$ -c_z_rot2 : sin(c_nick) * c_y_rot1 - cos(c_nick) * c_z_rot1$ -*/ - c_x_rot : cos(c_nick) * c_x$ + sin(c_nick) * c_z$ c_y_rot : c_y$ c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ +/* back to spheric coordinates */ a_h : (\pi/2 - acos(c_z_rot))$ a_v : atan(c_y_rot / c_x_rot)$ - /* angle over horizon in view direction */ a_h_dir : atan (tan (a_h) * sqrt(tan(a_v) ^2 + 1))$ -/* adjust angle according to nick value */ -/* a_v : atan(cos(c_nick - a_h ) * tan((m_view - c_view) / cos(a_h)))$ */ -/* a_v : m_view - c_view$ */ - x : tan(a_v)$ y : tan(-a_h_dir)$ x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ + +/* distortion correction */ d : x_rot ^ 2 + y_rot ^ 2$ dist_fact : d ^ 2 * k1 + d * k0$ x_dist : x_rot * (1 + dist_fact) * scale$ -- cgit v1.2.3 From f35a69d7bfb469f664735a1499d7eb553cdd597f Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 22 May 2008 16:47:56 +0200 Subject: comments and whitespace --- src/lsq_rectilinear.mac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index cea35e1..3c5b367 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -7,12 +7,13 @@ c_x : cos(m_nick) * cos(m_view - c_view)$ c_y : cos(m_nick) * sin(m_view - c_view)$ c_z : sin(m_nick)$ +/* nick rotation */ c_x_rot : cos(c_nick) * c_x$ + sin(c_nick) * c_z$ c_y_rot : c_y$ c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ -/* back to spheric coordinates */ -a_h : (\pi/2 - acos(c_z_rot))$ +/* back to spherical coordinates */ +a_h : \pi / 2 - acos(c_z_rot)$ a_v : atan(c_y_rot / c_x_rot)$ /* angle over horizon in view direction */ -- cgit v1.2.3 From bac85749b75971ee75d635bea3117f8a4f640e1c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 24 May 2008 00:08:29 +0200 Subject: major simplification of rectilinear projection --- src/lsq_rectilinear.mac | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index 3c5b367..4ed1e09 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -12,15 +12,8 @@ c_x_rot : cos(c_nick) * c_x$ + sin(c_nick) * c_z$ c_y_rot : c_y$ c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ -/* back to spherical coordinates */ -a_h : \pi / 2 - acos(c_z_rot)$ -a_v : atan(c_y_rot / c_x_rot)$ - -/* angle over horizon in view direction */ -a_h_dir : atan (tan (a_h) * sqrt(tan(a_v) ^2 + 1))$ - -x : tan(a_v)$ -y : tan(-a_h_dir)$ +x : c_y_rot / c_x_rot$ +y : - c_z_rot / c_x_rot$ x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ -- cgit v1.2.3 From d417ed2632eb97f133347db2201da447632a3dc9 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 24 May 2008 00:13:08 +0200 Subject: comments --- src/lsq_rectilinear.mac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index 4ed1e09..8e0c0f3 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -2,7 +2,7 @@ * rectilinear (pinhole) projection model with distortion correction */ -/* switch to cartesian coordinates for nick rotation */ +/* switch to cartesian coordinates */ c_x : cos(m_nick) * cos(m_view - c_view)$ c_y : cos(m_nick) * sin(m_view - c_view)$ c_z : sin(m_nick)$ @@ -12,8 +12,11 @@ c_x_rot : cos(c_nick) * c_x$ + sin(c_nick) * c_z$ c_y_rot : c_y$ c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ +/* pinhole projection */ x : c_y_rot / c_x_rot$ y : - c_z_rot / c_x_rot$ + +/* rotation around view axis */ x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ -- cgit v1.2.3 From a550b880fb9a28cba8ce0aa351444f1ef8ee8958 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 May 2008 18:12:50 +0200 Subject: fix stupid typo --- src/lsq_rectilinear.mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index 8e0c0f3..68dc5ee 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -8,7 +8,7 @@ c_y : cos(m_nick) * sin(m_view - c_view)$ c_z : sin(m_nick)$ /* nick rotation */ -c_x_rot : cos(c_nick) * c_x$ + sin(c_nick) * c_z$ +c_x_rot : cos(c_nick) * c_x + sin(c_nick) * c_z$ c_y_rot : c_y$ c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ -- cgit v1.2.3 From 090788ca04d1620c258d3a1e9053b907e87ec3c1 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 May 2008 18:43:14 +0200 Subject: whitespace --- src/lsq_rectilinear.mac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index 68dc5ee..377c24a 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -14,10 +14,10 @@ c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ /* pinhole projection */ x : c_y_rot / c_x_rot$ -y : - c_z_rot / c_x_rot$ +y : -c_z_rot / c_x_rot$ /* rotation around view axis */ -x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ +x_rot : y * sin(c_tilt) + x * cos(c_tilt) + x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ /* distortion correction */ -- cgit v1.2.3 From 2dfdc09969b8c32887cb45b6f7ff286227ddfd27 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 28 May 2008 19:18:53 +0200 Subject: use numerical more stable distance formula --- src/Panorama.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 32e14f4..8bab3e4 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -413,8 +413,11 @@ Panorama::update_coordinates() { double Panorama::distance(double phi, double lam) { - return acos(sin(view_phi) * sin(phi) + - cos(view_phi) * cos(phi) * cos(view_lam - lam)); + double d_lam = view_lam - lam; + + return atan2(sqrt(pow(cos(phi) * sin(d_lam), 2.0) + + pow(cos(view_phi) * sin(phi) - sin(view_phi) * cos(phi) * cos(d_lam), 2.0)), + sin(view_phi) * sin(phi) + cos(view_phi) * cos(phi) * cos(d_lam)); } double @@ -428,7 +431,6 @@ Panorama::alpha(const Hill *m) { return fmod(atan2(sin_alph, cos_alph) + 2.0 * pi_d, 2.0 * pi_d); } - double Panorama::nick(const Hill *m) { double b, c; -- cgit v1.2.3