Remove scale parameter from distortion correction

Scale is no longer useful in LensCorrection::correctDistortion. Remove
the scale parameter from the functions.
This commit is contained in:
Lawrence 2020-01-02 18:33:35 -08:00
parent 512517327f
commit b266cb7ca3
5 changed files with 16 additions and 20 deletions

View File

@ -267,7 +267,7 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
} }
if (pLCPMap && params->lensProf.useDist) { if (pLCPMap && params->lensProf.useDist) {
pLCPMap->correctDistortion(x_d, y_d, 0, 0, 1); pLCPMap->correctDistortion(x_d, y_d, 0, 0);
} }
// rotate // rotate
@ -946,7 +946,7 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
} }
if (enableLCPDist) { 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 // rotate

View File

@ -1030,16 +1030,16 @@ bool rtengine::LCPMapper::isCACorrectionAvailable() const
return enableCA; 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; x += cx;
y += cy; y += cy;
if (isFisheye) { if (isFisheye) {
const double u = x * scale; const double u = x;
const double v = y * scale; const double v = y;
const double u0 = mc.x0 * scale; const double u0 = mc.x0;
const double v0 = mc.y0 * scale; const double v0 = mc.y0;
const double du = (u - u0); const double du = (u - u0);
const double dv = (v - v0); const double dv = (v - v0);
const double fx = mc.fx; 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 k1 = mc.param[0];
const double k2 = mc.param[1]; const double k2 = mc.param[1];
const double r = sqrt(du * du + dv * dv); 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 th = atan2(r, f);
const double th2 = th * th; const double th2 = th * th;
const double cfact = (((k2 * th2 + k1) * th2 + 1) * th) / r; 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; x = ud;
y = vd; y = vd;
} else { } else {
x *= scale; const double x0 = mc.x0;
y *= scale; const double y0 = mc.y0;
const double x0 = mc.x0 * scale;
const double y0 = mc.y0 * scale;
const double xd = (x - x0) / mc.fx, yd = (y - y0) / mc.fy; const double xd = (x - x0) / mc.fx, yd = (y - y0) / mc.fy;
const LCPModelCommon::Param aDist = mc.param; 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; y = ynew * mc.fy + y0;
} }
x -= cx * scale; x -= cx;
y -= cy * scale; y -= cy;
} }
void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int channel) const void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int channel) const

View File

@ -168,7 +168,7 @@ private:
class LensCorrection { class LensCorrection {
public: public:
virtual ~LensCorrection() {} 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 bool isCACorrectionAvailable() const = 0;
virtual void correctCA(double &x, double &y, int cx, int cy, int channel) 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; 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; bool isCACorrectionAvailable() const override;
void correctCA(double& x, double& y, int cx, int cy, int channel) 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; void processVignette(int width, int height, float** rawData) const override;

View File

@ -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_) { if (!data_) {
return; return;
@ -67,8 +67,6 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy, double
x -= cx; x -= cx;
y -= cy; y -= cy;
} }
x *= scale;
y *= scale;
} }

View File

@ -53,7 +53,7 @@ public:
explicit operator bool() const; 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; bool isCACorrectionAvailable() const override;
void correctCA(double &x, double &y, int cx, int cy, int channel) 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; void processVignette(int width, int height, float** rawData) const override;