Move profiled distortion correction in pipeline
Lensfun/LCP distortion correction was applied before automatic scaling and perspective correction in the inverse transformation. This means it was applied after scaling and perspective in the pipeline. It should actually come first.
This commit is contained in:
parent
fbc7455ead
commit
512517327f
@ -253,15 +253,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
|
||||
|
||||
if (needsPerspective()) {
|
||||
// horizontal perspective transformation
|
||||
@ -273,6 +266,10 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
|
||||
y_d *= maxRadius * vpcospt / (maxRadius - y_d * vptanpt);
|
||||
}
|
||||
|
||||
if (pLCPMap && params->lensProf.useDist) {
|
||||
pLCPMap->correctDistortion(x_d, y_d, 0, 0, 1);
|
||||
}
|
||||
|
||||
// rotate
|
||||
double Dx = x_d * cost - y_d * sint;
|
||||
double Dy = x_d * sint + y_d * cost;
|
||||
@ -935,15 +932,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
|
||||
|
||||
if (enablePerspective) {
|
||||
// horizontal perspective transformation
|
||||
@ -955,6 +945,10 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
|
||||
y_d *= maxRadius * vpcospt / (maxRadius - y_d * vptanpt);
|
||||
}
|
||||
|
||||
if (enableLCPDist) {
|
||||
pLCPMap->correctDistortion(x_d, y_d, w2, h2, 1); // must be first transform
|
||||
}
|
||||
|
||||
// rotate
|
||||
const double Dxc = x_d * cost - y_d * sint;
|
||||
const double Dyc = x_d * sint + y_d * cost;
|
||||
|
Loading…
x
Reference in New Issue
Block a user