{"id":1257,"date":"2020-11-17T02:41:17","date_gmt":"2020-11-17T02:41:17","guid":{"rendered":"https:\/\/rossedwards.co.uk\/blog\/?p=1257"},"modified":"2020-11-17T18:31:50","modified_gmt":"2020-11-17T18:31:50","slug":"testing-nasa-ames-stereo-pipeline","status":"publish","type":"post","link":"https:\/\/rossedwards.co.uk\/blog\/2020\/11\/17\/testing-nasa-ames-stereo-pipeline\/","title":{"rendered":"Testing NASA AMES Stereo Pipeline"},"content":{"rendered":"\n<p>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 &#8216;<a href=\"https:\/\/www.iarpa.gov\/challenges\/3dchallenge.html\">Multiple view Stereo 3D Mapping challenge<\/a>&#8216;. The entries that secured 2nd and 3rd place used variation&#8217;s of <a href=\"https:\/\/github.com\/NeoGeographyToolkit\/StereoPipeline\">Ames Stereo Pipeine (ASP)<\/a> NASA&#8217;s automated, open-source pipeline for mass production of digital elevation models (DEMs) from very high-resolution commercial stereo satellite imagery. I couldn&#8217;t wait to dig deeper and review it&#8217;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:<\/p>\n\n\n\n<p><strong>SGM (Semi-Global Matching)<\/strong> &#8211; a proven stereo algorithm with widesread popularity.<\/p>\n\n\n\n<p><strong>MGM (More Global Matching)<\/strong> &#8211; is a variation of SGM that can produce superior output at the cost of longer run-time and higher memory usage.<\/p>\n\n\n\n<p>I added a red background on every resulting raster to highlight area&#8217;s where the algorithm had not been able to process. Click below image to see animated testing:<\/p>\n\n\n\n<div class=\"wp-block-envira-envira-gallery\"><div id=\"envira-gallery-wrap-1258\" class=\"envira-gallery-wrap envira-gallery-theme-base envira-lightbox-theme-base\" itemscope itemtype=\"https:\/\/schema.org\/ImageGallery\"><div data-row-height=\"\" data-gallery-theme=\"\" id=\"envira-gallery-1258\" class=\"envira-gallery-public  envira-gallery-1-columns envira-clear enviratope envira-gallery-css-animations\" data-envira-columns=\"1\"><div id=\"envira-gallery-item-1256\" class=\"envira-gallery-item enviratope-item envira-gallery-item-1 envira-lazy-load\" style=\"padding-left: 1px; padding-bottom: 1px; padding-right: 1px;\"  itemscope itemtype=\"https:\/\/schema.org\/ImageObject\"><div class=\"envira-gallery-item-inner\"><div class=\"envira-gallery-position-overlay  envira-gallery-top-left\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-top-right\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-bottom-left\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-bottom-right\"><\/div><a href=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/Peek-2020-11-17-01-24.gif\" class=\"envira-gallery-1258 envira-gallery-link\" rel=\"enviragallery1258\" title=\"QGIS layers to manage comparison of algorithm permutations\" data-envira-caption=\"QGIS layers to manage comparison of algorithm permutations\" data-envira-retina=\"\" data-thumbnail=\"\"  itemprop=\"contentUrl\"><div class=\"envira-lazy\" data-test-width=\"640\" data-test-height=\"480\" style=\"padding-bottom:75%;\"><img id=\"envira-gallery-image-1256\" class=\"envira-gallery-image envira-gallery-image-1\" data-envira-index=\"1\" src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/Peek-2020-11-17-01-24-1024x489-640x480.gif\" data-envira-src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/Peek-2020-11-17-01-24-1024x489-640x480.gif\" data-envira-gallery-id=\"1258\" data-envira-item-id=\"1256\" data-envira-caption=\"QGIS layers to manage comparison of algorithm permutations\" alt=\"\" title=\"QGIS layers to manage comparison of algorithm permutations\"  itemprop=\"thumbnailUrl\" data-envira-srcset=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/Peek-2020-11-17-01-24-1024x489-640x480.gif 400w,https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/Peek-2020-11-17-01-24-1024x489-640x480.gif 2x\" srcset=\"data:image\/gif;base64,R0lGODlhAQABAIAAAP\/\/\/\/\/\/\/yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" \/><\/div><\/a><\/div><\/div><\/div><\/div><noscript><img src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/Peek-2020-11-17-01-24.gif\" alt=\"\" \/><\/noscript><\/div>\n\n\n\n<!--more-->\n\n\n\n<p>Initial results using default algorithm on Digital Globe data with following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>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<\/code><\/pre>\n\n\n\n<div class=\"wp-block-envira-envira-gallery\"><div id=\"envira-gallery-wrap-1271\" class=\"envira-gallery-wrap envira-gallery-theme-base envira-lightbox-theme-base\" itemscope itemtype=\"https:\/\/schema.org\/ImageGallery\"><div data-row-height=\"\" data-gallery-theme=\"\" id=\"envira-gallery-1271\" class=\"envira-gallery-public  envira-gallery-1-columns envira-clear enviratope envira-gallery-css-animations\" data-envira-columns=\"1\"><div id=\"envira-gallery-item-1270\" class=\"envira-gallery-item enviratope-item envira-gallery-item-1 envira-lazy-load\" style=\"padding-left: 1px; padding-bottom: 1px; padding-right: 1px;\"  itemscope itemtype=\"https:\/\/schema.org\/ImageObject\"><div class=\"envira-gallery-item-inner\"><div class=\"envira-gallery-position-overlay  envira-gallery-top-left\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-top-right\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-bottom-left\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-bottom-right\"><\/div><a href=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/AMES3-1.png\" class=\"envira-gallery-1271 envira-gallery-link\" rel=\"enviragallery1271\" title=\"Result of stereo process on WorldView 1B data\" data-envira-caption=\"Result of stereo process on WorldView 1B data\" data-envira-retina=\"\" data-thumbnail=\"\"  itemprop=\"contentUrl\"><div class=\"envira-lazy\" data-test-width=\"640\" data-test-height=\"480\" style=\"padding-bottom:75%;\"><img id=\"envira-gallery-image-1270\" class=\"envira-gallery-image envira-gallery-image-1\" data-envira-index=\"1\" src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/AMES3-1-1024x524-640x480.png\" data-envira-src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/AMES3-1-1024x524-640x480.png\" data-envira-gallery-id=\"1271\" data-envira-item-id=\"1270\" data-envira-caption=\"Result of stereo process on WorldView 1B data\" alt=\"\" title=\"Result of stereo process on WorldView 1B data\"  itemprop=\"thumbnailUrl\" data-envira-srcset=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/AMES3-1-1024x524-640x480.png 400w,https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/AMES3-1-1024x524-640x480.png 2x\" srcset=\"data:image\/gif;base64,R0lGODlhAQABAIAAAP\/\/\/\/\/\/\/yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" \/><\/div><\/a><\/div><\/div><\/div><\/div><noscript><img src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/AMES3-1.png\" alt=\"\" \/><\/noscript><\/div>\n\n\n\n<p>I then switched to the <strong>SGM algorithm<\/strong> to see the potential difference in accuracy and resolution of detail:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>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<\/code><\/pre>\n\n\n\n<p>I gained some resolution, but lost detail\/definition on building and landscape edges (lighter layer is SGM):<\/p>\n\n\n\n<div class=\"wp-block-envira-envira-gallery\"><div id=\"envira-gallery-wrap-1275\" class=\"envira-gallery-wrap envira-gallery-theme-base envira-lightbox-theme-base\" itemscope itemtype=\"https:\/\/schema.org\/ImageGallery\"><div data-row-height=\"\" data-gallery-theme=\"\" id=\"envira-gallery-1275\" class=\"envira-gallery-public  envira-gallery-1-columns envira-clear enviratope envira-gallery-css-animations\" data-envira-columns=\"1\"><div id=\"envira-gallery-item-1274\" class=\"envira-gallery-item enviratope-item envira-gallery-item-1 envira-lazy-load\" style=\"padding-left: 1px; padding-bottom: 1px; padding-right: 1px;\"  itemscope itemtype=\"https:\/\/schema.org\/ImageObject\"><div class=\"envira-gallery-item-inner\"><div class=\"envira-gallery-position-overlay  envira-gallery-top-left\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-top-right\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-bottom-left\"><\/div><div class=\"envira-gallery-position-overlay  envira-gallery-bottom-right\"><\/div><a href=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/default_vs_MGM.gif\" class=\"envira-gallery-1275 envira-gallery-link\" rel=\"enviragallery1275\" title=\"Default algorithm vs SGM\" data-envira-caption=\"Default algorithm vs SGM\" data-envira-retina=\"\" data-thumbnail=\"\"  itemprop=\"contentUrl\"><div class=\"envira-lazy\" data-test-width=\"640\" data-test-height=\"480\" style=\"padding-bottom:75%;\"><img id=\"envira-gallery-image-1274\" class=\"envira-gallery-image envira-gallery-image-1\" data-envira-index=\"1\" src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/default_vs_MGM-640x480.gif\" data-envira-src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/default_vs_MGM-640x480.gif\" data-envira-gallery-id=\"1275\" data-envira-item-id=\"1274\" data-envira-caption=\"Default algorithm vs SGM\" alt=\"\" title=\"Default algorithm vs SGM\"  itemprop=\"thumbnailUrl\" data-envira-srcset=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/default_vs_MGM-640x480.gif 400w,https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/default_vs_MGM-640x480.gif 2x\" srcset=\"data:image\/gif;base64,R0lGODlhAQABAIAAAP\/\/\/\/\/\/\/yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" \/><\/div><\/a><\/div><\/div><\/div><\/div><noscript><img src=\"https:\/\/rossedwards.co.uk\/blog\/wp-content\/uploads\/2020\/11\/default_vs_MGM.gif\" alt=\"\" \/><\/noscript><\/div>\n\n\n\n<p><strong>Key steps of the Stereo pipeline broken down &#8211;<\/strong><\/p>\n\n\n\n<p><strong>Stage 0 <\/strong>(Preprocessing)<\/p>\n\n\n\n<p>calls <strong>stereo_pprc<\/strong>. Multi-threaded<\/p>\n\n\n\n<p>Normalizes the two\nimages and aligns them by locating interest points and matching them in both\nimages. The program is designed to reject outlying interest points. This stage\nwrites out the pre-aligned images and the image masks. <\/p>\n\n\n\n<p>Output&nbsp; <strong>*-L.tif <\/strong>&nbsp;&nbsp;<strong>*-R.tif<\/strong><\/p>\n\n\n\n<p><strong>Stage 1<\/strong> (Disparity Map Initialization) <\/p>\n\n\n\n<p>calls <strong>stereo_corr<\/strong>. Multi-threaded<\/p>\n\n\n\n<p>performs pyramid\ncorrelation and builds a rough disparity map that is used to seed the sub-pixel\nrefinement phase. <\/p>\n\n\n\n<p>Output&nbsp; <strong>*-D.tif<\/strong><\/p>\n\n\n\n<p><strong>Stage 2<\/strong> (Blend) <\/p>\n\n\n\n<p>calls <strong>stereo_blend<\/strong>. Multi-threaded.<\/p>\n\n\n\n<p>blend the borders of\nadjacent tiles. Only needed for parallel stereo with the SGM\/MGM algorithms.\nSkipped otherwise. <\/p>\n\n\n\n<p><strong>Stage 3<\/strong> (Sub-pixel Refinement) <\/p>\n\n\n\n<p>calls <strong>stereo_rfne<\/strong>. Multi-threaded<\/p>\n\n\n\n<p>performs sub-pixel\ncorrelation that refines the disparity map. <\/p>\n\n\n\n<p>Output&nbsp; <strong>*-RD.tif<\/strong><\/p>\n\n\n\n<p><strong>Stage 4<\/strong> (Outlier Rejection and Hole Filling) <\/p>\n\n\n\n<p>calls <strong>stereo_fltr<\/strong>. Multi-threaded<\/p>\n\n\n\n<p>performs filtering\nof the disparity map and (optionally) fills in holes using an inpainting\nalgorithm. This phase also creates a &#8220;good pixel&#8221; map. <\/p>\n\n\n\n<p>Output&nbsp; <strong>*-F.tif<\/strong><\/p>\n\n\n\n<p><strong>Stage 5<\/strong> (Triangulation) <\/p>\n\n\n\n<p>calls <strong>stereo_tri<\/strong>. Multi-threaded<\/p>\n\n\n\n<p>generates a 3D point\ncloud from the disparity map. <\/p>\n\n\n\n<p>Output&nbsp; <strong>*-PC.tif<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/groups.google.com\/g\/ames-stereo-pipeline-support\">Check out the great support forum for ASP<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8216;Multiple view Stereo 3D Mapping challenge&#8216;. The entries that secured 2nd and 3rd place used variation&#8217;s of Ames Stereo Pipeine (ASP) NASA&#8217;s automated, open-source pipeline for mass production of &hellip; <span class=\"read-more\"><a href=\"https:\/\/rossedwards.co.uk\/blog\/2020\/11\/17\/testing-nasa-ames-stereo-pipeline\/\" class=\"more-link\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1268,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,4],"tags":[],"_links":{"self":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1257"}],"collection":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=1257"}],"version-history":[{"count":22,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1257\/revisions"}],"predecessor-version":[{"id":1312,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1257\/revisions\/1312"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/media\/1268"}],"wp:attachment":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=1257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=1257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=1257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}