[gdal-dev] gdal_fillnodata.py filling interior holes in RGB images
Brian Case
rush at winkey.org
Wed Oct 12 13:00:02 EDT 2011
Travis,
you have to run gdal_fillnodata on each band, then splice the outputs
back together.
if the nodata areas on the inside do not connect to the outside area you
could create an alpha band
### -color 0,0,0 assumes odata value of 0
nearblack -dstalpha -near 0 -nb 0 -setalpha -color 0,0,0 \
myfile.tif -o mytmpfile.tif
gdal_translate -b 4 -of VRT mytmpfile.tif a.vrt
gdal_fillnodata.py -md 1 -b 1 myfile.tif r_filled.tif
gdal_fillnodata.py -md 1 -b 2 myfile.tif g_filled.tif
gdal_fillnodata.py -md 1 -b 3 myfile.tif b_filled.tif
gdalbuildvrt -resolution highest -separate filled.vrt \
r_filled.tif g_filled.tif b_filled.tif a.vrt
if you want an rgba image use
gdal_translate filled.vrt filled.tif
otherwise for rgb with nodata use
### INIT_DEST=0 assumes nodata value of 0
gdalwarp -wo INIT_DEST=0 filled.vrt filled.tif
if your interior nodata areas connect to the outside nodata areas. I
don't know howto deal with that other than to just live with the extra
pixel around the outside of the valid data.
Brian
On Wed, 2011-10-12 at 08:46 -0400, Travis Kirstine wrote:
> I have some RGB orthophotos that have interior holes, typically 1
> pixel. Most of the images have "valid" nodata around the edges. I
> would like to fill the interior holes while maintaining the valid
> nodata around the edges. I have tried gdal_fillnodata.py but cannot
> get the utility to return a multiband image and / or interpolate only
> interior holes.
>
> Any help would be much appreciated
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list