Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with lens distortion computation #488

Open
oleg-alexandrov opened this issue Oct 26, 2024 · 0 comments
Open

Issues with lens distortion computation #488

oleg-alexandrov opened this issue Oct 26, 2024 · 0 comments

Comments

@oleg-alexandrov
Copy link
Collaborator

This is similar to #461, but applies to the cahvor distortion model.

For cahvor distortion, the formula (https://github.com/DOI-USGS/usgscsm/blob/main/src/Distortion.cpp#L325) is:

 double rr = shiftedDx * shiftedDx + shiftedDy * shiftedDy;

  if (rr > tolerance)
  {
    double dr = opticalDistCoeffs[0] +
                (rr * (opticalDistCoeffs[1] + rr * opticalDistCoeffs[2]));

    ux = shiftedDx * (1.0 - dr);
    uy = shiftedDy * (1.0 - dr);
    ux += opticalDistCoeffs[3];
    uy += opticalDistCoeffs[4];
  }
}
break;

When rr is smaller than tolerance, the undistortion ux and uy is assumed to be equal to input distorted values, which is wrong.

Need to add the optical shifts given by opticalDistCoeffs[3] and [4] even when rr is small.

This formula should not have an if statement at all. This is a simple polynomial formula, that works for any input.

The same for cahvor undistortion, at https://github.com/DOI-USGS/usgscsm/blob/main/src/Distortion.cpp#L585

There is no need to consider a tolerance. The only division by a value is:

dx = shiftedUx / (1.0 - drOverR);
dy = shiftedUy / (1.0 - drOverR);

and here it doesn't matter if we are close to the origin, as that does not make 1.0 - drOverR be equal to 0, rather, this quantity is close to 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant