[gdal-dev] nearblack on multi GB images very slow

mhw-at-yg matt.wilkie at gov.yk.ca
Fri Mar 12 10:50:50 PST 2021


I have a lot of multi GB images that are unfortunately jpeg-in-geotiff
encoded before nodata was properly defined. As a result they all suffer from
the jagged edges problem.
<http://osgeo-org.1560.x6.nabble.com/file/t192661/WVpPW.png> 

I've defined a method for adding a nodata mask side-car file that works
around this: 
https://gis.stackexchange.com/questions/387877/add-a-nodata-mask-or-alpha-band-to-read-only-image/

 * Create a working copy de-collared image with a mask file
 * Rename the mask file to match original
 * Remove working copy

Windows command line syntax:

:::
nearblack -o xxx.tif -setmask in_image.tif
move xxx.tif.msk in_image.tif.msk
del xxx.*
:::

Unfortunately nearblack is unusable on large images. With a source image of
3.9 GB (126015 x 68149 pixels, 3 channels) it was only at 35% after 17
hours. I forgot about the process and rebooted my machine so I don't know
how long it would taken to complete, if it would have finished at all.

I used gdal_retile to break the source into 4096x4096 tiles and ran
nearblack on those. It finished in under 2 hours for the entire set of 527
files, but i can't use the result because the tiles aren't georeferenced
(see other thread). That problem aside, the experiment demonstrates much
optimization is possible. 

Any advice on how else I might solve this?







-----
-Matt
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list