Merge branch 'dev' into bayer_bilinear

This commit is contained in:
Ingo Weyrich
2020-06-25 21:01:54 +02:00
5 changed files with 26 additions and 36 deletions

View File

@@ -491,15 +491,8 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
for (size_t i = 0; i < src.size(); i++) {
double x_d = src[i].x, y_d = src[i].y;
if (pLCPMap && params->lensProf.useDist) {
pLCPMap->correctDistortion(x_d, y_d, 0, 0, ascale);
} else {
x_d *= ascale;
y_d *= ascale;
}
x_d += ascale * (0 - w2); // centering x coord & scale
y_d += ascale * (0 - h2); // centering y coord & scale
y_d = ascale * (y_d - h2); // centering x coord & scale
x_d = ascale * (x_d - w2); // centering x coord & scale
switch (perspectiveType) {
case PerspType::NONE:
@@ -522,6 +515,10 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
break;
}
if (pLCPMap && params->lensProf.useDist) {
pLCPMap->correctDistortion(x_d, y_d, 0, 0);
}
// rotate
double Dx = x_d * cost - y_d * sint;
double Dy = x_d * sint + y_d * cost;
@@ -1219,15 +1216,8 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
double x_d = x;
double y_d = y;
if (enableLCPDist) {
pLCPMap->correctDistortion(x_d, y_d, cx, cy, ascale); // must be first transform
} else {
x_d *= ascale;
y_d *= ascale;
}
x_d += ascale * centerFactorx; // centering x coord & scale
y_d += ascale * centerFactory; // centering y coord & scale
x_d = ascale * (x_d + centerFactorx); // centering x coord & scale
y_d = ascale * (y_d + centerFactory); // centering y coord & scale
switch (perspectiveType) {
case PerspType::NONE:
@@ -1250,6 +1240,10 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
break;
}
if (enableLCPDist) {
pLCPMap->correctDistortion(x_d, y_d, w2, h2);
}
// rotate
const double Dxc = x_d * cost - y_d * sint;
const double Dyc = x_d * sint + y_d * cost;

View File

@@ -990,16 +990,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 = static_cast<double>(mc.x0) * scale;
const double v0 = static_cast<double>(mc.y0) * scale;
const double u = x;
const double v = y;
const double u0 = static_cast<double>(mc.x0);
const double v0 = static_cast<double>(mc.y0);
const double du = (u - u0);
const double dv = (v - v0);
const double fx = mc.fx;
@@ -1007,7 +1007,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;
@@ -1017,10 +1017,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 = static_cast<double>(mc.x0) * scale;
const double y0 = static_cast<double>(mc.y0) * scale;
const double x0 = static_cast<double>(mc.x0);
const double y0 = static_cast<double>(mc.y0);
const double xd = (x - x0) / static_cast<double>(mc.fx), yd = (y - y0) / static_cast<double>(mc.fy);
const auto& aDist = mc.param;
@@ -1037,8 +1035,8 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy
y = ynew * static_cast<double>(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

View File

@@ -166,7 +166,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;
@@ -194,7 +194,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;
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;

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_) {
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;
}

View File

@@ -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;