DOI-USGS / usgscsm

This repository stores USGS Community Sensor Model (CSM) camera models
Other
26 stars 33 forks source link

Support for radial and tangential distortion model #465

Closed oleg-alexandrov closed 6 months ago

oleg-alexandrov commented 9 months ago

I wonder if there is any interest in supporting in CSM the lens distortion model that has both radial and tangential distortion. This is the most used distortion model for a generic frame camera.

CSM has now only a radial distortion model (no tangential component), and then specialized distortion models for LRO NAC, Kaguya, etc. There is also a "Transverse" distortion model, using polynomials of degree 3 in x and y, with 20 overall coefficients, but while this may fit anything, but it looks vastly overdetermined and not sure how much it gets used in practice.

The classical lens distortion model has 2 coefficients for tangential distortion, and 2 (and sometimes 3) for radial component. Here's the doc: image

(source: https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#calibratecamera, ignore everything except relationship between x', y' and x'', y'', and ignore the denominator coefficients there, so use only k1, k2, k3, p1, p2).

I am asking for this since I plan to the use CSM model for various sensors in ASP, and fitting radial + tangential distortion is really the first thing one should try for a new sensor.

I can do the work, and it will be very much along the lines of existing Transverse model implementation, but with different polynomials.

jlaura commented 9 months ago

Huge 👍. Having a generic distortion model with radial and tangential coefficients would be absolutely terrific. Is there a planetary sensor (I don't know one off the top of my head) example that it might make sense to include in ALE since that is one place where many example ISDs are coming from?

oleg-alexandrov commented 9 months ago

I made a pull request at https://github.com/DOI-USGS/usgscsm/pull/466

The closest distortion model in ALE to the radial-tangential (radtan) distortion model I just added is the one for DawnFC. That one has only one distortion coefficient, for radial distortion.

For DawnFC, and for the new radtan model, the polynomial formula gets applied when pixels are distorted, and an iterative method is used for undistortion. Note that the existing "radial" distortion model uses a similar formula but it gets applied at undistortion stage.

I added a test in the usgscsm repo for how to load and test an ISD with the new radtan distortion, using an ISD based on DawnFC. I am not sure I need to add anything also to the "ale" repo except for the actual code.

jlaura commented 6 months ago

@oleg-alexandrov Is this good to close? I see #575 and #466 both merged, so I think this is done.

oleg-alexandrov commented 6 months ago

Yep, this was done. I've also done a lot of testing in ASP recently, with producing and evaluating how well this distortion works in fitting a camera model, and it does well.