lens profile: report availability of distortion and vignetting

Beside CA, report also distortion and vignetting availability. Rename
is${CORRECTION}Available methods to has${CORRECTION}.
This commit is contained in:
Simone Gotti 2024-06-13 20:03:07 +02:00
parent dc0e23c82c
commit b98fa42857
5 changed files with 43 additions and 12 deletions

View File

@ -518,7 +518,7 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
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;
if (pLCPMap && params->lensProf.useDist) { if (pLCPMap && params->lensProf.useDist && pLCPMap->hasDistortionCorrection()) {
pLCPMap->correctDistortion(Dx, Dy, w2, h2); pLCPMap->correctDistortion(Dx, Dy, w2, h2);
} }
@ -1077,8 +1077,8 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
// set up stuff, depending on the mode we are // set up stuff, depending on the mode we are
enum PerspType { NONE, SIMPLE, CAMERA_BASED }; enum PerspType { NONE, SIMPLE, CAMERA_BASED };
const bool enableLCPDist = pLCPMap && params->lensProf.useDist; const bool enableLCPDist = pLCPMap && params->lensProf.useDist && pLCPMap->hasDistortionCorrection();
const bool enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable(); const bool enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->hasCACorrection();
const bool enableCA = highQuality && needsCA(); const bool enableCA = highQuality && needsCA();
const bool doCACorrection = enableCA || enableLCPCA; const bool doCACorrection = enableCA || enableLCPCA;
const bool enableGradient = needsGradient(); const bool enableGradient = needsGradient();

View File

@ -985,11 +985,23 @@ rtengine::LCPMapper::LCPMapper(
isFisheye = pProf->isFisheye; isFisheye = pProf->isFisheye;
} }
bool rtengine::LCPMapper::isCACorrectionAvailable() const bool rtengine::LCPMapper::hasDistortionCorrection() const
{
// assume lcp always provides distortion correction
return true;
}
bool rtengine::LCPMapper::hasCACorrection() const
{ {
return enableCA; return enableCA;
} }
bool rtengine::LCPMapper::hasVignettingCorrection() const
{
// assume lcp always provides vignetting correction
return true;
}
void rtengine::LCPMapper::correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const void rtengine::LCPMapper::correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const
{ {
correctDistortion(x, y, cx, cy); correctDistortion(x, y, cx, cy);

View File

@ -167,9 +167,12 @@ class LensCorrection {
public: public:
virtual ~LensCorrection() {} virtual ~LensCorrection() {}
virtual bool hasDistortionCorrection() const = 0;
virtual bool hasCACorrection() const = 0;
virtual bool hasVignettingCorrection() const = 0;
virtual void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const = 0; 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 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; virtual void correctCA(double &x, double &y, int cx, int cy, int channel) const = 0;
virtual void processVignette(int width, int height, float** rawData) const = 0; virtual void processVignette(int width, int height, float** rawData) const = 0;
virtual void processVignette3Channels(int width, int height, float** rawData) const = 0; virtual void processVignette3Channels(int width, int height, float** rawData) const = 0;
@ -196,9 +199,12 @@ public:
); );
bool hasDistortionCorrection() const override;
bool hasCACorrection() const override;
bool hasVignettingCorrection() const override;
void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const override; 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; 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; void correctCA(double& x, double& y, int cx, int cy, int channel) const override;
void processVignette(int width, int height, float** rawData) const override; void processVignette(int width, int height, float** rawData) const override;
void processVignette3Channels(int width, int height, float** rawData) const override; void processVignette3Channels(int width, int height, float** rawData) const override;

View File

@ -102,6 +102,21 @@ LFModifier::operator bool() const
} }
bool LFModifier::hasDistortionCorrection() const
{
return (flags_ & LF_MODIFY_DISTORTION);
}
bool LFModifier::hasCACorrection() const
{
return (flags_ & LF_MODIFY_TCA);
}
bool LFModifier::hasVignettingCorrection() const
{
return (flags_ & LF_MODIFY_VIGNETTING);
}
void LFModifier::correctDistortion(double &x, double &y, int cx, int cy) const void LFModifier::correctDistortion(double &x, double &y, int cx, int cy) const
{ {
if (!data_) { if (!data_) {
@ -125,11 +140,6 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy) const
} }
} }
bool LFModifier::isCACorrectionAvailable() const
{
return (flags_ & LF_MODIFY_TCA);
}
void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) const void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) const
{ {
assert(channel >= 0 && channel <= 2); assert(channel >= 0 && channel <= 2);

View File

@ -53,9 +53,12 @@ public:
explicit operator bool() const; explicit operator bool() const;
bool hasDistortionCorrection() const override;
bool hasCACorrection() const override;
bool hasVignettingCorrection() const override;
void correctDistortionAndCA(double &x, double &y, int cx, int cy, int channel) const override; 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; 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; void correctCA(double &x, double &y, int cx, int cy, int channel) const override;
void processVignette(int width, int height, float** rawData) const override; void processVignette(int width, int height, float** rawData) const override;
void processVignette3Channels(int width, int height, float** rawData) const override; void processVignette3Channels(int width, int height, float** rawData) const override;