Whilst looking for the best available open source solution to generate terrain heightmaps from satellite stereo pairs, I stumbled upon the results of an international IARPA ‘Multiple view Stereo 3D Mapping challenge‘. The entries that secured 2nd and 3rd place used variation’s of Ames Stereo Pipeine (ASP) NASA’s automated, open-source pipeline for mass production of digital elevation models (DEMs) from very high-resolution commercial stereo satellite imagery. I couldn’t wait to dig deeper and review it’s capabilities. I started by setting up a QGIS project file which allowed me to load up my results from numerous test runs covering every key permutation available for the 2 most successful algorithms, this enabled quick comparison of sometimes subtle differences in results:
SGM (Semi-Global Matching) – a proven stereo algorithm with widesread popularity.
MGM (More Global Matching) – is a variation of SGM that can produce superior output at the cost of longer run-time and higher memory usage.
I added a red background on every resulting raster to highlight area’s where the algorithm had not been able to process. Click below image to see animated testing:
Initial results using default algorithm on Digital Globe data with following command:
stereo_gui -t dg --subpixel-mode 2 --alignment-method affineepipolar 12FEB16101327-P1BS-056082198020_01_P001.TIF 12FEB16101426-P1BS-056082198020_01_P001.TIF 12FEB16101327-P1BS-056082198020_01_P001.XML 12FEB16101426-P1BS-056082198020_01_P001.XML result_2/out
I then switched to the SGM algorithm to see the potential difference in accuracy and resolution of detail:
stereo --stereo-algorithm 1 --corr-tile-size 4000 --cost-mode 3 --corr-kernel 9 9 12FEB16101426-P1BS-056082198020_01_P001.TIF 12FEB16101327-P1BS-056082198020_01_P001.TIF 12FEB16101426-P1BS-056082198020_01_P001.XML 12FEB16101327-P1BS-056082198020_01_P001.XML result_test_26_SGM/output --left-image-crop-win 27895 3411 3052 2297 --right-image-crop-win 28347 3552 3142 2932
I gained some resolution, but lost detail/definition on building and landscape edges (lighter layer is SGM):
Key steps of the Stereo pipeline broken down –
Stage 0 (Preprocessing)
calls stereo_pprc. Multi-threaded
Normalizes the two images and aligns them by locating interest points and matching them in both images. The program is designed to reject outlying interest points. This stage writes out the pre-aligned images and the image masks.
Output *-L.tif *-R.tif
Stage 1 (Disparity Map Initialization)
calls stereo_corr. Multi-threaded
performs pyramid correlation and builds a rough disparity map that is used to seed the sub-pixel refinement phase.
Stage 2 (Blend)
calls stereo_blend. Multi-threaded.
blend the borders of adjacent tiles. Only needed for parallel stereo with the SGM/MGM algorithms. Skipped otherwise.
Stage 3 (Sub-pixel Refinement)
calls stereo_rfne. Multi-threaded
performs sub-pixel correlation that refines the disparity map.
Stage 4 (Outlier Rejection and Hole Filling)
calls stereo_fltr. Multi-threaded
performs filtering of the disparity map and (optionally) fills in holes using an inpainting algorithm. This phase also creates a “good pixel” map.
Stage 5 (Triangulation)
calls stereo_tri. Multi-threaded
generates a 3D point cloud from the disparity map.