[gdal-dev] Nearblack Eating Image Border

Even Rouault even.rouault at spatialys.com
Wed Feb 20 05:03:32 PST 2019


On mardi 19 février 2019 18:13:16 CET Christopher Mitchell wrote:
> I've encountered an error in an image processing pipeline I've built
> where nearblack is removing pixels at the border of images, even if
> they don't fit the is-"black" criterion. Specifically, I'm using
> nearblack to remove nearly-black areas touching the edges of lossy
> image tiles that should be fully black. Those images are later
> combined into VRT files and warped; where we have multiple tiles
> overlapping an area, some of which are missing data, we therefore can
> get complete coverage.
> 
> Unfortunately, for tiles that have no black areas, nearblack is still
> eating the -nb argument's number of pixels at the edges, turning them
> into black (0, 0, 0, 0, where we're using 4-channel images), even if
> those pixels are nowhere near the color criterion to be recognized as
> black. My understanding was that nearblack should only be proceeding
> into the interior of the non-black area and then setting pixels to
> black if those pixels are /actually/ nearly black.
> 
> Am I encountering a bug with nearblack? Do I misunderstand how the -nb
> argument works? Happy to provide a MWE if any of the above is unclear,
> and thanks in advance.

Yes, what you observe is logical regarding how the algorithm is coded, 
although I can understand this may not be the desired effect. Currently, 
nearblack will always "eat" -nb pixels from all sides, whereas it should 
probably only do so if transitionning from an area where the nearblack 
criterion was satisfied to an area where it is no longer satisfied.

You may file a ticket about that to https://github.com/OSGeo/gdal/issues

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list