merge branch 'lensprofile-ca-correction' into 'dev'
This commit is contained in:
@@ -72,7 +72,7 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy, double
|
||||
|
||||
bool LFModifier::isCACorrectionAvailable() const
|
||||
{
|
||||
return false;
|
||||
return (flags_ & LF_MODIFY_TCA);
|
||||
}
|
||||
|
||||
#ifdef __GNUC__ // silence warning, can be removed when function is implemented
|
||||
@@ -80,8 +80,29 @@ bool LFModifier::isCACorrectionAvailable() const
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
|
||||
void LFModifier::correctCA(double &x, double &y, int channel) const
|
||||
void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) const
|
||||
{
|
||||
assert(channel >= 0 && channel <= 2);
|
||||
|
||||
// agriggio: RT currently applies the CA correction per channel, whereas
|
||||
// lensfun applies it to all the three channels simultaneously. This means
|
||||
// we do the work 3 times, because each time we discard 2 of the 3
|
||||
// channels. We could consider caching the info to speed this up
|
||||
x += cx;
|
||||
y += cy;
|
||||
|
||||
float pos[6];
|
||||
if (swap_xy_) {
|
||||
std::swap(x, y);
|
||||
}
|
||||
data_->ApplySubpixelDistortion(x, y, 1, 1, pos);
|
||||
x = pos[2*channel];
|
||||
y = pos[2*channel+1];
|
||||
if (swap_xy_) {
|
||||
std::swap(x, y);
|
||||
}
|
||||
x -= cx;
|
||||
y -= cy;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -117,6 +138,11 @@ Glib::ustring LFModifier::getDisplayString() const
|
||||
ret += "vignetting";
|
||||
sep = ", ";
|
||||
}
|
||||
if (flags_ & LF_MODIFY_TCA) {
|
||||
ret += sep;
|
||||
ret += "CA";
|
||||
sep = ", ";
|
||||
}
|
||||
if (flags_ & LF_MODIFY_SCALE) {
|
||||
ret += sep;
|
||||
ret += "autoscaling";
|
||||
@@ -262,6 +288,15 @@ bool LFLens::hasDistortionCorrection() const
|
||||
}
|
||||
}
|
||||
|
||||
bool LFLens::hasCACorrection() const
|
||||
{
|
||||
if (data_) {
|
||||
return data_->CalibTCA;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LFDatabase
|
||||
@@ -443,7 +478,7 @@ std::unique_ptr<LFModifier> LFDatabase::getModifier(const LFCamera &camera, cons
|
||||
if (data_) {
|
||||
if (camera && lens) {
|
||||
lfModifier *mod = lfModifier::Create(lens.data_, camera.getCropFactor(), width, height);
|
||||
int flags = LF_MODIFY_DISTORTION | LF_MODIFY_SCALE;
|
||||
int flags = LF_MODIFY_DISTORTION | LF_MODIFY_SCALE | LF_MODIFY_TCA;
|
||||
if (aperture > 0) {
|
||||
flags |= LF_MODIFY_VIGNETTING;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user