DOI-USGS / usgscsm

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

Potential issue with stopping criterion for the linescan sensor ground-to-image computation #433

Open oleg-alexandrov opened 1 year ago

oleg-alexandrov commented 1 year ago

I made ASP have the option of using the CSM model for the DigitalGlobe WorldView linescan sensor (for now this is not the default). This sensor has a large focal length (2 million pixels) which exposed some vulnerabilities in the ground-to-image computation in the linescan sensor of the usgscsm library.

The current logic goes like this (https://github.com/USGS-Astrogeology/usgscsm/blob/dev/src/UsgsAstroLsSensorModel.cpp#L733):

Let f(line) be projection of a ground point in the linescan sensor using the camera center and orientation at given line. To find the line where this ground point truly projects to, solve the equation f(line) = 0 using the secant method:

line2 = line1 - f(line1) * (line1 - line0) / (f(line1) - f(line0)).

Stop iterating when f(line2) < desiredPrecision. Return line2.

The first issue here is that the stopping criterion is not right, I think. If the desired precision is 1e-8, we want the solved line to be accurate to within 1e-8, regardless of what f(line) is, such as 1e-6 or 1e-12, for example. As of now, the algorithm can either stop prematurely or do too much work, which can actually make things worse (see below).

The second issue is that this algorithm can produce junk if the desired precision is, for example, 1e-12, as the differences in the equation above are so small that their ratio is inaccurate. I got bitten by this and took a while to figure out where exactly the issue was. (The large focal length for the WorldView sensor amplifies some of the errors.)

Note that the current algorithm is in fact my implementation, but the stopping criterion is from before, I think.

I am not proposing any changes for now. I am only stating that this algorithm is fragile. One should never ask for a desired precision less than 1e-8, as the algorithm will return junk. Then, at some point, we should revisit the stopping criterion.

Lastly, this is not an academic exercise. For bundle adjustment, to return a very accurate ground-to-image result is very important, since otherwise the results of that may not be good.

acpaquette commented 1 year ago

Sweet! Thank you for pointing this out @oleg-alexandrov! @jlaura This may be why we are also seeing problems in KaguyaTC?

jlaura commented 1 year ago

@acpaquette I don't think it is likely because the the TC focal length is ~75mm and CTX is ~352mm. So, I would expect that if this were the cause of the issue @oleg-alexandrov describes, we would see it more in CTX. A quick google search suggests that the DigitalGlobe WorldView sensor focal length is ~1300mm, so quite large in comparison to the two planetary sensors.

If I had to guess the issue is in the distortion model. We'll need to pull some LROC-NAC images and compare the Kaguya TC locations to the NAC locations in ISIS and CSM to see what the alignment looks like and to help determine which sensor model is more correct I think.

oleg-alexandrov commented 1 year ago

Speaking of distortion, and likely this won't solve your issue either, and I think @jessemapel may know better, but as I recall, the ground-to-image calculation is done assuming no distortion, and it is applied only after the correct line is found. It is not fully clear to me if this is correct, or if distortion must be applied while the line is being found. I guess it is assumed that distortion modifies sample positions along each line, but not the position of each line, which may be a fair assumption if the sensor line is goes precisely though the center of the lens, or wherever the distortion is assumed to be very minimal.

dshean commented 1 year ago

Thanks for the update @oleg-alexandrov!

One correction - the WorldView-1 focal length is ~8000 mm (~8 m), WorldView-2 focal lengths is ~13000 mm (~13 m) and WorldView-3 focal length is ~16000 mm (~16 m). With 8 micron pitch, we end up with Oleg's 2E6 px focal length estimate. HiRISE has ~12 m focal length.

I agree with Oleg's comment about when the linescan distortion correction is applied. We can't assume that the line will intersect the optical center, especially for TDI linescan detector arrays with along-track offsets. These offsets can be several cm, potentially with non-negligible distortion.

Fortunately, we don't need to worry about this for the WorldView sensors, as all bands in the L1B products are delivered using a "virtual linescan" sensor model with no distortion or principal point offset.

jlaura commented 1 year ago

@dshean 13m!!! I thought 1.3m was a bit excessive when I misread that.