Move de-fish to distortion
This commit is contained in:
@@ -471,6 +471,10 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
|
||||
((params->perspective.camera_focal_length > 0) ? params->perspective.camera_focal_length : PerspectiveParams::DEFAULT_CAMERA_FOCAL_LENGTH)
|
||||
* ((params->perspective.camera_crop_factor > 0) ? params->perspective.camera_crop_factor : PerspectiveParams::DEFAULT_CAMERA_CROP_FACTOR)
|
||||
* (maxRadius / sqrt(18.0*18.0 + 12.0*12.0));
|
||||
const double f_defish =
|
||||
((params->distortion.focal_length > 0) ? params->distortion.focal_length : DistortionParams::DEFAULT_FOCAL_LENGTH)
|
||||
* ((params->perspective.camera_crop_factor > 0) ? params->perspective.camera_crop_factor : PerspectiveParams::DEFAULT_CAMERA_CROP_FACTOR)
|
||||
* (maxRadius / sqrt(18.0*18.0 + 12.0*12.0));
|
||||
const double p_camera_yaw = params->perspective.camera_yaw / 180.0 * rtengine::RT_PI;
|
||||
const double p_camera_pitch = params->perspective.camera_pitch / 180.0 * rtengine::RT_PI;
|
||||
const double p_camera_roll = params->perspective.camera_roll * rtengine::RT_PI_180;
|
||||
@@ -517,12 +521,13 @@ bool ImProcFunctions::transCoord (int W, int H, const std::vector<Coord2D> &src,
|
||||
|
||||
x_d /= params->perspective.camera_scale;
|
||||
y_d /= params->perspective.camera_scale;
|
||||
if (params->perspective.camera_defish) {
|
||||
x_d /= f;
|
||||
y_d /= f;
|
||||
if (params->distortion.defish) {
|
||||
x_d /= f_defish;
|
||||
y_d /= f_defish;
|
||||
|
||||
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_defish * std::atan(r) / r;
|
||||
|
||||
x_d *= factor;
|
||||
y_d *= factor;
|
||||
@@ -1178,6 +1183,10 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
|
||||
((params->perspective.camera_focal_length > 0) ? params->perspective.camera_focal_length : PerspectiveParams::DEFAULT_CAMERA_FOCAL_LENGTH)
|
||||
* ((params->perspective.camera_crop_factor > 0) ? params->perspective.camera_crop_factor : PerspectiveParams::DEFAULT_CAMERA_CROP_FACTOR)
|
||||
* (maxRadius / sqrt(18.0*18.0 + 12.0*12.0));
|
||||
const double f_defish =
|
||||
((params->distortion.focal_length > 0) ? params->distortion.focal_length : DistortionParams::DEFAULT_FOCAL_LENGTH)
|
||||
* ((params->perspective.camera_crop_factor > 0) ? params->perspective.camera_crop_factor : PerspectiveParams::DEFAULT_CAMERA_CROP_FACTOR)
|
||||
* (maxRadius / sqrt(18.0*18.0 + 12.0*12.0));
|
||||
const double p_camera_yaw = params->perspective.camera_yaw / 180.0 * rtengine::RT_PI;
|
||||
const double p_camera_pitch = params->perspective.camera_pitch / 180.0 * rtengine::RT_PI;
|
||||
const double p_camera_roll = params->perspective.camera_roll * rtengine::RT_PI_180;
|
||||
@@ -1255,12 +1264,12 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
|
||||
|
||||
x_d /= params->perspective.camera_scale;
|
||||
y_d /= params->perspective.camera_scale;
|
||||
if (params->perspective.camera_defish) {
|
||||
x_d /= f;
|
||||
y_d /= f;
|
||||
if (params->distortion.defish) {
|
||||
x_d /= f_defish;
|
||||
y_d /= f_defish;
|
||||
|
||||
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_defish * std::atan(r) / r;
|
||||
|
||||
x_d *= factor;
|
||||
y_d *= factor;
|
||||
@@ -1485,7 +1494,9 @@ bool ImProcFunctions::needsCA () const
|
||||
|
||||
bool ImProcFunctions::needsDistortion () const
|
||||
{
|
||||
return fabs (params->distortion.amount) > 1e-15;
|
||||
return
|
||||
params->distortion.defish ||
|
||||
fabs (params->distortion.amount) > 1e-15;
|
||||
}
|
||||
|
||||
bool ImProcFunctions::needsRotation () const
|
||||
@@ -1509,7 +1520,6 @@ bool ImProcFunctions::needsPerspective () const
|
||||
params->perspective.projection_shift_horiz ||
|
||||
params->perspective.projection_shift_vert ||
|
||||
params->perspective.projection_yaw ||
|
||||
params->perspective.camera_defish ||
|
||||
params->perspective.camera_scale > 1.0 + 1e-6 ||
|
||||
params->perspective.camera_scale < 1.0 - 1e-6 ));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user