iptransform: apply distortion and CA correction in a single pass

Some lens profile methods provides a way to correct distortion and CA in
a single step.

When available, applying distortion and CA correction when both enabled
in a single pass is more precise (see lensfun
ApplySubpixelGeometryDistortion doc) since it's usually how the profile
is done. Instead applying the CA correction in a step after distortion
correction could lead to a bit different (also if not always visible)
correction.

This is also required for future lens correction methods (like DNG
WarpRectilinear or corrections based on vendor metadata) that provides
only merged distortion and CA correction in a single pass.
This commit is contained in:
Simone Gotti
2024-06-13 20:02:15 +02:00
parent 55fd4b975e
commit dc0e23c82c
5 changed files with 42 additions and 8 deletions

View File

@@ -166,6 +166,8 @@ private:
class LensCorrection {
public:
virtual ~LensCorrection() {}
virtual void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) 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;
@@ -194,6 +196,7 @@ public:
);
void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) 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;