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++) {
|
for (size_t i = 0; i < src.size(); i++) {
|
||||||
double x_d = src[i].x, y_d = src[i].y;
|
double x_d = src[i].x, y_d = src[i].y;
|
||||||
|
|
||||||
if (pLCPMap && params->lensProf.useDist) {
|
y_d = ascale * (y_d - h2); // centering x coord & scale
|
||||||
pLCPMap->correctDistortion(x_d, y_d, 0, 0, ascale);
|
x_d = ascale * (x_d - w2); // centering x coord & scale
|
||||||
} 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
|
|
||||||
|
|
||||||
if (needsPerspective()) {
|
if (needsPerspective()) {
|
||||||
// horizontal perspective transformation
|
// 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);
|
y_d *= maxRadius * vpcospt / (maxRadius - y_d * vptanpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pLCPMap && params->lensProf.useDist) {
|
||||||
|
pLCPMap->correctDistortion(x_d, y_d, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// rotate
|
// rotate
|
||||||
double Dx = x_d * cost - y_d * sint;
|
double Dx = x_d * cost - y_d * sint;
|
||||||
double Dy = x_d * sint + y_d * cost;
|
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 x_d = x;
|
||||||
double y_d = y;
|
double y_d = y;
|
||||||
|
|
||||||
if (enableLCPDist) {
|
x_d = ascale * (x_d + centerFactorx); // centering x coord & scale
|
||||||
pLCPMap->correctDistortion(x_d, y_d, cx, cy, ascale); // must be first transform
|
y_d = ascale * (y_d + centerFactory); // centering y coord & scale
|
||||||
} else {
|
|
||||||
x_d *= ascale;
|
|
||||||
y_d *= ascale;
|
|
||||||
}
|
|
||||||
|
|
||||||
x_d += ascale * centerFactorx; // centering x coord & scale
|
|
||||||
y_d += ascale * centerFactory; // centering y coord & scale
|
|
||||||
|
|
||||||
if (enablePerspective) {
|
if (enablePerspective) {
|
||||||
// horizontal perspective transformation
|
// horizontal perspective transformation
|
||||||
@ -955,6 +945,10 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
|
|||||||
y_d *= maxRadius * vpcospt / (maxRadius - y_d * vptanpt);
|
y_d *= maxRadius * vpcospt / (maxRadius - y_d * vptanpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enableLCPDist) {
|
||||||
|
pLCPMap->correctDistortion(x_d, y_d, w2, h2, 1); // must be first transform
|
||||||
|
}
|
||||||
|
|
||||||
// rotate
|
// rotate
|
||||||
const double Dxc = x_d * cost - y_d * sint;
|
const double Dxc = x_d * cost - y_d * sint;
|
||||||
const double Dyc = x_d * sint + y_d * cost;
|
const double Dyc = x_d * sint + y_d * cost;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user