added support for CA correction via lensfun
Performance could be improved (see the comments marked "agriggio" in iptransform.cc and rtlensfun.cc)
This commit is contained in:
@@ -72,12 +72,29 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy, double
|
||||
|
||||
bool LFModifier::isCACorrectionAvailable() const
|
||||
{
|
||||
return false;
|
||||
return (flags_ & LF_MODIFY_TCA);
|
||||
}
|
||||
|
||||
|
||||
void LFModifier::correctCA(double &x, double &y, 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
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +126,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";
|
||||
@@ -245,6 +267,15 @@ bool LFLens::hasDistortionCorrection() const
|
||||
}
|
||||
}
|
||||
|
||||
bool LFLens::hasCACorrection() const
|
||||
{
|
||||
if (data_) {
|
||||
return data_->CalibTCA;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LFDatabase
|
||||
@@ -428,7 +459,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