From 8b51d8297fb20e59684f05b581e9d200fa49ab47 Mon Sep 17 00:00:00 2001 From: Alexander Brock Date: Sat, 25 Feb 2023 21:59:25 +0100 Subject: [PATCH] Move de-fishing code _before_ distortion correction, so de-fishing occurs _after_ distortion correction. --- rtengine/iptransform.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 74c9f91c2..ea96f9608 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -515,10 +515,6 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, break; } - if (pLCPMap && params->lensProf.useDist) { - pLCPMap->correctDistortion(x_d, y_d, w2, h2); - } - x_d /= params->perspective.camera_scale; y_d /= params->perspective.camera_scale; if (params->perspective.camera_defish) { @@ -532,6 +528,10 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector &src, y_d *= factor; } + if (pLCPMap && params->lensProf.useDist) { + pLCPMap->correctDistortion(x_d, y_d, w2, h2); + } + // rotate double Dx = x_d * cost - y_d * sint; double Dy = x_d * sint + y_d * cost; @@ -1253,10 +1253,6 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I break; } - if (enableLCPDist) { - pLCPMap->correctDistortion(x_d, y_d, w2, h2); - } - x_d /= params->perspective.camera_scale; y_d /= params->perspective.camera_scale; if (params->perspective.camera_defish) { @@ -1264,12 +1260,16 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I y_d /= f; const double r = std::sqrt(x_d * x_d + y_d * y_d); - const double factor = f * std::atan(r)/r; + const double factor = f * std::atan(r) / r; x_d *= factor; y_d *= factor; } + 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;