{"id":1465,"date":"2019-03-01T18:27:12","date_gmt":"2019-03-01T22:27:12","guid":{"rendered":"https:\/\/www.openbible.info\/blog\/?p=1465"},"modified":"2019-03-04T13:18:35","modified_gmt":"2019-03-04T17:18:35","slug":"using-machine-learning-to-enhance-the-resolution-of-bible-maps","status":"publish","type":"post","link":"https:\/\/www.openbible.info\/blog\/2019\/03\/using-machine-learning-to-enhance-the-resolution-of-bible-maps\/","title":{"rendered":"Using Machine Learning to Enhance the Resolution of Bible Maps"},"content":{"rendered":"\n<p>In a previous post, I discussed how <a href=\"https:\/\/www.openbible.info\/blog\/2018\/12\/using-3d-software-to-enhance-the-resolution-of-bible-maps\/\">3D software could improve the resolution of Bible maps<\/a> by fractally enhancing a digital elevation model and then synthetically creating landcover. In this post I&#8217;ll look at how machine learning can increase the resolution of freely available satellite images to generate realistic-looking historical maps.<\/p>\n\n\n\n<h3>Acquiring satellite imagery<\/h3>\n\n\n\n<p>The European <a href=\"https:\/\/en.wikipedia.org\/wiki\/Sentinel-2\">Sentinel-2<\/a> satellites take daily photos of much of the earth at a ten-meter optical resolution (i.e., one pixel represents a ten-meter square on the ground). The U.S. operates a similar system, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Landsat_8\">Landsat 8<\/a>, with a fifteen-meter resolution. Commercial vendors offer much higher-resolution imagery, similar to what you find in Google Maps, at a prohibitive cost (thousands of dollars). By contrast, both Sentinel-2 and Landsat are government-operated and have freely available imagery. Here&#8217;s a comparison of <a href=\"https:\/\/apps.sentinel-hub.com\/eo-browser\/?lat=31.77133&amp;lng=35.48092&amp;zoom=16&amp;time=2017-11-17&amp;preset=1_TRUE_COLOR&amp;datasource=Sentinel-2%20L2A\">the<\/a> <a href=\"https:\/\/apps.sentinel-hub.com\/eo-browser\/?lat=31.77133&amp;lng=35.48092&amp;zoom=16&amp;time=2017-11-20&amp;preset=2_TRUE_COLOR_PANSHARPENED&amp;datasource=Landsat%208%20USGS\">two<\/a>, zoomed in to level 16 (1.3 meters per pixel), or well above their actual resolution:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/a.openbible.info\/blog\/2019-03-sentinel-landsat.jpg\" alt=\"Sentinel-2 shows more washed-out colors at a higher resolution than Landsat 8.\"\/><\/figure>\n\n\n\n<p>The Sentinel-2 imagery looks sharper thanks to its higher resolution, though the processing to correct the color overexposes the light areas, in my opinion. Because I want to start with the sharpest imagery, for this post I&#8217;ll use Sentinel-2.<\/p>\n\n\n\n<p>I use <a href=\"https:\/\/www.sentinel-hub.com\/explore\/sentinel-playground\">Sentinel Playground<\/a> to find a scene that doesn&#8217;t have a lot of clouds and then download the L2A, or atmosphere- and color-corrected, imagery. If I were producing a large-scale map that involved stitching together multiple photos, I&#8217;d use something like <a href=\"http:\/\/www.cesbio.ups-tlse.fr\/multitemp\/#Sen2Agri\">Sen2Agri<\/a> to create a mosaic of many images, or a &#8220;basemap&#8221; (as in Google Maps). (Doing so is complicated and beyond the scope of this post.)<\/p>\n\n\n\n<p>I choose a fourteen-kilometer-wide <a href=\"https:\/\/apps.sentinel-hub.com\/eo-browser\/?lat=31.80019&amp;lng=35.33349&amp;zoom=13\">scene from January 2018<\/a> showing a mix of developed and undeveloped land near the northwest corner of the Dead Sea at a resolution of ten meters per pixel. I lower the gamma to 0.5 so that the colors approximately match the colors in Google Maps to allow for easier comparisons.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/a.openbible.info\/blog\/2019-03-sentinel-original.jpg\"><img src=\"https:\/\/a.openbible.info\/blog\/2019-03-sentinel-original.jpg\" alt=\"The Sentinel-2 scene.\" width=\"800\"\/><\/a><\/figure>\n\n\n\n<h3>Increasing resolution<\/h3>\n\n\n\n<p>&#8220;<a href=\"https:\/\/tvtropes.org\/pmwiki\/pmwiki.php\/Main\/EnhanceButton\">Enhance!<\/a>&#8221; is a staple of crime dramas, where a technician magically increases the resolution of a photo to provide crucial evidence needed by the plot. Super-resolution doesn&#8217;t work as well in reality as it does in fiction, but machine learning algorithms have increased in their sophistication in the past two years, and I thought it would be worth seeing how they performed on satellite photos. Here&#8217;s a detail of the above image, as enlarged by four different algorithms, plus Google Maps as the &#8220;ground truth.&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/a.openbible.info\/blog\/2019-03-super-resolution.jpg\" alt=\"Comparison of four different super-resolution algorithms plus Google Maps, as discussed in the following paragraphs.\"\/><\/figure>\n\n\n\n<p>Each algorithm increases the original resolution by four times, providing a theoretical resolution of 2.5 meters per pixel.<\/p>\n\n\n\n<p>The first, &#8220;raw pixels,&#8221; is the simplest; each pixel in the original image now occupies sixteen pixels (4&#215;4). It was instantaneous to produce.<\/p>\n\n\n\n<p>The second, &#8220;Photoshop Preserve Details 2.0,&#8221; uses the machine-learning algorithm built into recent versions of Photoshop. This algorithm took a few seconds to run. <a href=\"https:\/\/a.openbible.info\/blog\/2019-03-photoshop.jpg\">Generated image<\/a> (1 MB).<\/p>\n\n\n\n<p>The third, ESRGAN as implemented in <a href=\"https:\/\/runwayapp.ai\/\">Runway<\/a>, reflects a state-of-the-art super-resolution algorithm for photos, though it&#8217;s not optimized for satellite imagery. This algorithm took about a minute to run on a &#8220;cloud GPU.&#8221; <a href=\"https:\/\/a.openbible.info\/blog\/2019-03-esrgan.jpg\">Generated image<\/a> (1 MB).<\/p>\n\n\n\n<p>The fourth, <a href=\"https:\/\/topazlabs.com\/ai-gigapixel\/\">Gigapixel<\/a>, uses a <a href=\"https:\/\/topazlabs.com\/let-ai-sharpen-your-photos\/\">proprietary algorithm<\/a> to sharpen photos; it also isn&#8217;t optimized for satellite imagery. This algorithm took about an hour to run on a CPU. <a href=\"https:\/\/a.openbible.info\/blog\/2019-03-gigapixel.jpg\">Generated image<\/a> (6 MB).<\/p>\n\n\n\n<p>The fifth, <a href=\"https:\/\/www.google.com\/maps\/place\/Jerusalem,+Israel\/@31.7841766,35.4522806,5795m\/data=!3m1!1e3!4m5!3m4!1s0x1502d7d634c1fc4b:0xd96f623e456ee1cb!8m2!3d31.768319!4d35.21371\">Google Maps<\/a>, reflects actual high-resolution (my guess is around 3.7 meters per pixel) photography.<\/p>\n\n\n\n<h3>Discussion<\/h3>\n\n\n\n<p>To my eye, the Gigapixel enlargement looks sharpest; it plausibly adds detail, though I don&#8217;t think anyone would mistake it for an actual 2.5-meter resolution satellite photo.<\/p>\n\n\n\n<p>The stock ESRGAN enlargement doesn&#8217;t look quite as good to me; however, in my opinion, ESRGAN offers a lot of potential if tweaked. The algorithm already shows promise in <a href=\"https:\/\/www.resetera.com\/threads\/ai-neural-networks-being-used-to-generate-hq-textures-for-older-games-you-can-do-it-yourself.88272\/\">upscaling video-game textures<\/a>&#8211;a use the algorithm&#8217;s creators didn&#8217;t envision&#8211;and I think that taking the existing model developed by the researchers and training it further on satellite photos could produce higher-quality images.<\/p>\n\n\n\n<p>I didn&#8217;t test the one <a href=\"https:\/\/github.com\/CosmiQ\/VDSR4Geo\">purpose-built satellite image super-resolution algorithm<\/a> I found because it&#8217;s designed for much-higher-resolution (thirty-centimeter) input imagery.<\/p>\n\n\n\n<h3>Removing modern features<\/h3>\n\n\n\n<p>One problem with using satellite photos as the base for historical maps involves dealing with modern features: agriculture, cities, roads, etc., that weren&#8217;t around in the same form in the time period the historical map is depicting. Machine learning presents a solution for this problem, as well; Photoshop&#8217;s content-aware fill allows you to select an area of an image for Photoshop to plausibly fill in with similar content. For example, here&#8217;s the Gigapixel-enlarged image with human-created features removed by content-aware fill:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/a.openbible.info\/blog\/2019-03-content-aware-big.jpg\"><img src=\"https:\/\/a.openbible.info\/blog\/2019-03-content-aware.jpg\" alt=\"Modern features no longer appear in the image.\"\/><\/a><\/figure>\n\n\n\n<p>I made these edits by hand, but at scale you could use OpenStreetMap&#8217;s land-use data to mask candidate areas for content-aware replacement:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.openstreetmap.org\/#map=14\/31.7798\/35.4631\"><img src=\"https:\/\/a.openbible.info\/blog\/2019-03-openstreetmap-landuse.jpg\" alt=\"Data from OpenStreetMap shows roads, urban areas, farmland, etc.\"\/><\/a><\/figure>\n\n\n\n<h3>Conclusion<\/h3>\n\n\n\n<p>If you want to work with satellite imagery to produce a high-resolution basemap for historical or Bible maps, then using machine learning both to sharpen them and to remove modern features could be a viable, if time-consuming, process. The image in this post covers about 100 square kilometers; modern Israel is over 20,000 square kilometers. And this scene contains a mostly undeveloped area; large-scale cities are harder to erase with content-aware fill because there&#8217;s less surrounding wilderness for the algorithm to work with. But if you&#8217;re willing to put in the work, the result could be a free, plausibly realistic, reasonably detailed map over which you can overlay your own data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous post, I discussed how 3D software could improve the resolution of Bible maps by fractally enhancing a digital elevation model and then synthetically creating landcover. In this post I&#8217;ll look at how machine learning can increase the resolution of freely available satellite images to generate realistic-looking historical maps. Acquiring satellite imagery The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[34,1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/posts\/1465"}],"collection":[{"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/comments?post=1465"}],"version-history":[{"count":3,"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/posts\/1465\/revisions"}],"predecessor-version":[{"id":1469,"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/posts\/1465\/revisions\/1469"}],"wp:attachment":[{"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/media?parent=1465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/categories?post=1465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.openbible.info\/blog\/wp-json\/wp\/v2\/tags?post=1465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}