Lens corrections: apply CA correction after distortion, and not before

This commit is contained in:
Alberto Griggio 2018-04-11 11:03:07 +02:00
parent e518e7923e
commit dbb9fcd2b1

View File

@ -327,25 +327,29 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed,
} else { } else {
bool highQuality; bool highQuality;
std::unique_ptr<Imagefloat> tmpimg; std::unique_ptr<Imagefloat> tmpimg;
Imagefloat *dest = transformed;
if (!needsCA() && scale != 1) { if (!needsCA() && scale != 1) {
highQuality = false; highQuality = false;
} else { } else {
highQuality = true; highQuality = true;
// agriggio: CA correction via the lens profile has to be // agriggio: CA correction via the lens profile has to be
// performed before all the other transformations (except for the // performed before separately from the the other transformations
// coarse rotation/flipping). In order to not change the code too // (except for the coarse rotation/flipping). In order to not
// much, I simply introduced a new mode // change the code too much, I simply introduced a new mode
// TRANSFORM_HIGH_QUALITY_CA, which applies *only* // TRANSFORM_HIGH_QUALITY_CA, which applies *only* profile-based
// profile-based CA correction. So, the correction in this case // CA correction. So, the correction in this case occurs in two
// occurs in two steps, using an intermediate temporary // steps, using an intermediate temporary image. There's room for
// image. There's room for optimization of course... // optimization of course...
if (pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()) { if (pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()) {
tmpimg.reset(new Imagefloat(original->getWidth(), original->getHeight())); tmpimg.reset(new Imagefloat(original->getWidth(), original->getHeight()));
transformLCPCAOnly(original, tmpimg.get(), cx, cy, pLCPMap.get()); dest = tmpimg.get();
original = tmpimg.get();
} }
} }
transformGeneral(highQuality, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get()); transformGeneral(highQuality, original, dest, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get());
if (highQuality && dest != transformed) {
transformLCPCAOnly(dest, transformed, cx, cy, pLCPMap.get());
}
} }
} }