From b266cb7ca3380257ec34ea8fe39772cb5a36f61a Mon Sep 17 00:00:00 2001 From: Lawrence Date: Thu, 2 Jan 2020 18:33:35 -0800 Subject: [PATCH] Remove scale parameter from distortion correction Scale is no longer useful in LensCorrection::correctDistortion. Remove the scale parameter from the functions. --- rtengine/iptransform.cc | 4 ++-- rtengine/lcp.cc | 22 ++++++++++------------ rtengine/lcp.h | 4 ++-- rtengine/rtlensfun.cc | 4 +--- rtengine/rtlensfun.h | 2 +- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index bc490ce82..668756b71 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -267,7 +267,7 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, } if (pLCPMap && params->lensProf.useDist) { - pLCPMap->correctDistortion(x_d, y_d, 0, 0, 1); + pLCPMap->correctDistortion(x_d, y_d, 0, 0); } // rotate @@ -946,7 +946,7 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I } if (enableLCPDist) { - pLCPMap->correctDistortion(x_d, y_d, w2, h2, 1); // must be first transform + pLCPMap->correctDistortion(x_d, y_d, w2, h2); // must be first transform } // rotate diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index c80a126f5..a4dea2055 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -1030,16 +1030,16 @@ bool rtengine::LCPMapper::isCACorrectionAvailable() const return enableCA; } -void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy, double scale) const +void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy) const { x += cx; y += cy; if (isFisheye) { - const double u = x * scale; - const double v = y * scale; - const double u0 = mc.x0 * scale; - const double v0 = mc.y0 * scale; + const double u = x; + const double v = y; + const double u0 = mc.x0; + const double v0 = mc.y0; const double du = (u - u0); const double dv = (v - v0); const double fx = mc.fx; @@ -1047,7 +1047,7 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy const double k1 = mc.param[0]; const double k2 = mc.param[1]; const double r = sqrt(du * du + dv * dv); - const double f = sqrt(fx*fy / (scale * scale)); + const double f = sqrt(fx*fy); const double th = atan2(r, f); const double th2 = th * th; const double cfact = (((k2 * th2 + k1) * th2 + 1) * th) / r; @@ -1057,10 +1057,8 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy x = ud; y = vd; } else { - x *= scale; - y *= scale; - const double x0 = mc.x0 * scale; - const double y0 = mc.y0 * scale; + const double x0 = mc.x0; + const double y0 = mc.y0; const double xd = (x - x0) / mc.fx, yd = (y - y0) / mc.fy; const LCPModelCommon::Param aDist = mc.param; @@ -1077,8 +1075,8 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy y = ynew * mc.fy + y0; } - x -= cx * scale; - y -= cy * scale; + x -= cx; + y -= cy; } void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int channel) const diff --git a/rtengine/lcp.h b/rtengine/lcp.h index 2e36fe113..e6ecbfc97 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -168,7 +168,7 @@ private: class LensCorrection { public: virtual ~LensCorrection() {} - virtual void correctDistortion(double &x, double &y, int cx, int cy, double scale) const = 0; + virtual void correctDistortion(double &x, double &y, int cx, int cy) const = 0; virtual bool isCACorrectionAvailable() const = 0; virtual void correctCA(double &x, double &y, int cx, int cy, int channel) const = 0; virtual void processVignette(int width, int height, float** rawData) const = 0; @@ -196,7 +196,7 @@ public: ); - void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override; // MUST be the first stage + void correctDistortion(double &x, double &y, int cx, int cy) const override; // MUST be the first stage bool isCACorrectionAvailable() const override; void correctCA(double& x, double& y, int cx, int cy, int channel) const override; void processVignette(int width, int height, float** rawData) const override; diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 7ffb9ad33..363819cf7 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -46,7 +46,7 @@ LFModifier::operator bool() const } -void LFModifier::correctDistortion(double &x, double &y, int cx, int cy, double scale) const +void LFModifier::correctDistortion(double &x, double &y, int cx, int cy) const { if (!data_) { return; @@ -67,8 +67,6 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy, double x -= cx; y -= cy; } - x *= scale; - y *= scale; } diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 2f3e4677d..51212c9b9 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -53,7 +53,7 @@ public: explicit operator bool() const; - void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override; + void correctDistortion(double &x, double &y, int cx, int cy) const override; bool isCACorrectionAvailable() const override; void correctCA(double &x, double &y, int cx, int cy, int channel) const override; void processVignette(int width, int height, float** rawData) const override;