NeoGeographyToolkit / StereoPipeline

The NASA Ames Stereo Pipeline is a suite of automated geodesy & stereogrammetry tools designed for processing planetary imagery captured from orbiting and landed robotic explorers on other planets.
Apache License 2.0
479 stars 168 forks source link

Alignment using hillshading can give wrong results #287

Closed oleg-alexandrov closed 2 years ago

oleg-alexandrov commented 4 years ago

The pc_align tool with the --initial-transform-from-hillshading option creates match points among hill-shaded images which are used to find an initial alignment. This function has outlier filtering, but it is not sufficiently robust. It should use RANSAC like we do in a lot of other places instead of doing a more naive filter of removing points that are not within the 75-th percentile with a factor. Normally this is good enough but can fail when there are just a handful of points.

adehecq commented 4 years ago

I thought the matching step in pc_align was running a RANSAC filtering. Isn't that the aim of the '--ransac-iterations 10000' argument in '--ipmatch-options'? I'm working with very difficult cases and pc_align has been really good at throwing away outliers so far, but with custom values for these parameters: --ipmatch-options "--inlier-threshold 10 --ransac-constraint similarity --ransac-iterations 100000"

oleg-alexandrov commented 2 years ago

Yes, ip matching is doing RANSAC on pixels. Then, after that, one is left with a set of 3D points among which a transform is being found. There RANSAC was not used but rather a much simpler outlier removal scheme based on percentiles. Normally it was doing the job given the RANSAC filtering done before that, but in rare occasions with few good points it would get confused.

Recently I added RANSAC for this 3D transform fit step too, so now this issue is solved.

I see that you use --inlier-threshold 10. The default is --inlier-threshold 100. The latter seems to be a little too high and likely would allow some outliers to squeak in (but hopefully not really bad ones), which now would be filtered by the second RANSAC. But lowering it as the default would require quite some testing, and it looks to me that maybe 10 is somewhat too little.

Anyhow, this is just to find the initial transform. From then on ICP would take over so if one is in the ballpark now then ICP would finish the job.

oleg-alexandrov commented 2 years ago

BTW, I tried decreasing the inlier threshold to 20 and too many good points went missing when doing ip matching among hillshaded DEMs. It could because the input DEMs to be aligned are at different resolutions usually, so 100 pixels in the higher resolution DEM may be as little as 5 pixels in the second DEM, so it may be worth being generous with removal of outliers based on pixel values.

adehecq commented 2 years ago

Yes, I had good results with a threshold of 10, but I try to have a reference DEM that has approximately the same resolution as my input DEM. Good to know that with the new RANSAC step, this threshold can be increased a bit.