Showing results for 
Search instead for 
Do you mean 

Identify and fill "holes" in an image

by Technical Evangelist on ‎03-30-2018 10:50 AM - edited on ‎02-21-2020 06:54 AM by Community Manager (906 Views)


Download model



Sometimes (especially when pan sharpening), some bands can get stretched below the original Minimum DN value. This can cause problems if the process stretches to 0 or below. If the output data is then truncated to Unsigned Integers all those values become 0s, leading to what might be considered "holes" in the image.


This issue came up recently with a customer, They had been running various pan sharpening techniques and some of the techniques resulted in pixels having some bands where the DN value was mapped to zero. In general not all of the bands were zero, but at least one was. When that band is displayed as grey scale (i.e. on its own) it will be considered "background" and therefore drawn transparent, showing the 2D View background color, or any underlying data layers, through at those locations. The customer considered this undesirable. 


The best way to take care of this is to make sure the 0s aren't introduced in the first place. This can be done by modifying the original pan sharpening model, for example, to ensure that image pixels are assigned to a non-background value (see this discussion on NoData handling).


However , if you have already produced data with this issue, the attached Model is designed to correct the pixel values.


Iterator sub-model:


In the Model, any pixels where all bands are 0s are left alone (on the the assumption that they represent true background areas), and of course any input NoData locations will remain NoData. But in all other cases DN values of 0 get set to 1. In addition, when the output file is written out, any pixels where all bands were (and remain) 0 are considered to be NoData and 0 is set as the NoData value (unless the output file format supports mask-based NoData, in which case a Mask is created).


Let's look at the issue in more depth - here's a screenshot showing a pan-sharpened Pleiades image displayed as a Falsecolor Infrared composite (bands 4,1,2).


Pan-sharpened Pleiades image displayed 4,1,2. Original Pleiades images © CNES (2012), Distribution AIRBUS DS


The 2D View's background color has been set to Yellow, so the upper left corner of the image, where all 4 bands have a value of 0, is transparent and showing the background color through. The remainder of the image appears "solid" with no Yellow showing through.


However if we change the display so that only Band 4 is displayed, patches of yellow start to appear in the naturally dark locations (generally shadows next to very bright features).


 Pan-sharpened Pleiades image displaying just Band 4. Note the "holes" in dark locations such as building shadows


This is because, at those locations, Band 4 had been truncated to a value of 0 by the pan sharpening process that had been previously applied. The other bands at those locations were not 0s, so the 4,1,2 display looked correct. But when displaying only a single band we see the effects of the band containing zeroes. 


If we run this data through the provided Model, and display just band 4 again, the results now look like the screenshot below.

The upper left corner is still transparent (because in the input image, all bands were 0 at that corner location and are now considered NoData in the output image), but the "real image" areas are now solid (because individual bands have been adjusted from 0 to 1).


 Image processed through Avoid_Holes_v16_5_0.gmdx, displaying just Band 4. No holes in shadow areas.  


Changing to a Color Infrared band combination (4,1,2) of the output image looks like the screenshot below:


  Image processed through Avoid_Holes_v16_5_0.gmdx and displayed as 4,1,2. 


That's it - DN values of 0 corrected to 1, except if all bands contained 0s.

on ‎01-10-2020 07:30 AM

Best regard Ian:

Thank very much, excellent contribution for us.