{"id":847,"date":"2019-01-07T11:38:08","date_gmt":"2019-01-07T10:38:08","guid":{"rendered":"http:\/\/jenacopterlabs.de\/?page_id=847"},"modified":"2019-01-07T11:38:08","modified_gmt":"2019-01-07T10:38:08","slug":"uav-ortho-color-balancing-in-pci","status":"publish","type":"page","link":"https:\/\/jenacopterlabs.de\/?page_id=847","title":{"rendered":"UAV Ortho Color Balancing in PCI"},"content":{"rendered":"<p>Ortho Color balancing for large\u00a0UAV\u00a0ortho mosaics can be a challenging task. Usually you start to get into troubles when illumination conditions are quickly changing &#8211; at sub-optimal conditions with clouds \u00a0and low illumination condition in spring or autumn. \u00a0color balancing in Agisoft does a good job but sometime we need more &#8211; here a hot spot correction and global adaption is sometimes needed. PCIs Orthoengine does a great job here.<\/p>\n<p>This is a small python script that uses the ortho corrected geotiff files from Agisoft and applies a local and global correction.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1. Head section of a Python PCI script<\/strong><\/p>\n<p>Here we \u00a0load some PCI libraries.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nprint &quot;&quot;\r\nprint &quot;***************************************************************&quot;\r\nprint &quot;&quot;\r\nprint &quot; -= SHESE 4 hainich ortho processing =-&quot;\r\nprint &quot; workflow&quot;\r\nprint &quot; Last modified 24112018&quot;\r\nprint &quot;&quot;\r\nprint &quot;***************************************************************&quot;\r\n# This script runs the following PPFs in a top-down sequence and generates a \r\n# ortho mosaic based on the input ortho images exported from AGISOFT Photoscan.\r\n# All orthos must have the same georef and resolution. \r\n# 1. mosrep\r\n# 2. mosdef\r\n# 3. mosrun\r\nimport sys \r\nimport os\r\nimport pci\r\nimport fnmatch\r\nfrom pci.fun import *\r\nfrom pci.lut import *\r\nfrom pci.fimport import fimport\r\nfrom pci.pcimod import pcimod\r\nfrom pci.model import model\r\nfrom pci.exceptions import *\r\nfrom pci.ortho import ortho\r\nfrom pci.mosprep import mosprep\r\nfrom pci.mosdef import mosdef\r\nfrom pci.mosrun import mosrun\r\nfrom pci.exceptions import PCIException\r\n<\/pre>\n<pre>The comments are defined using a hash sign - you can also put these comments directly behind any coded line<\/pre>\n<p><strong>2. The xml\u00a0section of the script that defines the processing parameters<\/strong><\/p>\n<p>where xml files are defined\u00a0&#8211; you usually want that from the user and not hard coded into your script &#8211; so f.e. using the following expression the user would have to start the script by typing:<\/p>\n<p>python pythonscriptname \/dir\/where\/the\/files\/are<\/p>\n<p>to start the script and to include the &#8220;InFolder&#8221; string\u00a0(in this example). We later use &#8220;InFolder&#8221; to place the string into pathname.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nmfile = r&quot;W:\\work-hainich\\Hainich08-2018\\exported-orthofiles&quot;\r\nsilfile = r&quot;W:\\work-hainich\\Hainich08-2018\\exported-orthofiles\\mosaic.xml&quot;\r\nnodatval = &#x5B;0]\r\nnormaliz = &quot;HotSpot&quot; #HotSpot method often useful for airphoto imagery\r\nbalspec = &quot;BUNDLE&quot;\r\ncutmthd = &quot;minsqdiff&quot;\r\n\r\ntry:\r\n mosprep(mfile, silfile, nodatval, &quot;&quot;, normaliz,\r\n balspec, &quot;&quot;, &quot;&quot;, &#x5B;], cutmthd)\r\nexcept PCIException, e:\r\n print e\r\nexcept Exception, e:\r\n print e\r\n\r\n## Create Mosaic Definition XML file to\r\nsilfile = r&quot;W:\\work-hainich\\Hainich08-2018\\exported-orthofiles\\mosaic.xml&quot;\r\nmdfile = r&quot;W:\\work-hainich\\Hainich08-2018\\exported-orthofiles\\mosaicdef.xml&quot;\r\ndbic = &#x5B;1,2,3]\r\ntispec = &quot;&quot;\r\ntipostrn = &quot;&quot;\r\nmapunits= &quot;UTM 32 D000&quot;\r\npxszout= &#x5B;0.03]\r\nblend = &#x5B;5]\r\nnodata = &#x5B;0]\r\nftype = &quot;PIX&quot;\r\nfoptions = &quot;&quot;\r\ntry:\r\n mosdef(silfile, mdfile, dbic, tispec, tipostrn, mapunits, pxszout, blend, nodata, ftype, foptions)\r\nexcept PCIException, e:\r\n print e\r\nexcept Exception, e:\r\n print e\r\n\r\n## Finally create the full resolution mosaic\r\noutdir = r&quot;W:\\work-hainich\\Hainich08-2018\\exported-orthofiles&quot;\r\ncrsrcmap = &quot;&quot;\r\n\r\ntry:\r\n mosrun(silfile, mdfile, outdir, &quot;&quot;, crsrcmap,\r\n &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;BILIN&quot;)\r\nexcept PCIException, e:\r\n print e\r\nexcept Exception, e:\r\n print e\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ortho Color balancing for large\u00a0UAV\u00a0ortho mosaics can be a challenging task. Usually you start to get into troubles when illumination conditions are quickly changing &#8211; at sub-optimal conditions with clouds \u00a0and low illumination condition in spring or autumn. \u00a0color balancing in Agisoft does a good job but sometime we need more &#8211; here a hot spot correction and global adaption&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":18,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-847","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false,"cd-small":false,"cd-medium":false,"cd-standard":false},"uagb_author_info":{"display_name":"S\u00f6ren Hese","author_link":"https:\/\/jenacopterlabs.de\/?author=1"},"uagb_comment_info":0,"uagb_excerpt":"Ortho Color balancing for large\u00a0UAV\u00a0ortho mosaics can be a challenging task. Usually you start to get into troubles when illumination conditions are quickly changing &#8211; at sub-optimal conditions with clouds \u00a0and low illumination condition in spring or autumn. \u00a0color balancing in Agisoft does a good job but sometime we need more &#8211; here a hot&hellip;","_links":{"self":[{"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=\/wp\/v2\/pages\/847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=847"}],"version-history":[{"count":5,"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=\/wp\/v2\/pages\/847\/revisions"}],"predecessor-version":[{"id":852,"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=\/wp\/v2\/pages\/847\/revisions\/852"}],"up":[{"embeddable":true,"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=\/wp\/v2\/pages\/18"}],"wp:attachment":[{"href":"https:\/\/jenacopterlabs.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}