[Gdal-dev] gdalwarp: getting rid of dark borders

Tapio Sokura oh2kku at iki.fi
Fri Jan 7 05:00:07 EST 2005


Thanks for the swift reply, Frank.

Frank Warmerdam wrote:
> Good question.  There is no automatic way to do this.  In theory what
> you need is something like the existing GDALSuggestedWarpOutput()
> function used by gdalwarp, but that take the largest window completely
> filled with data instead of the smallest window completely containing
> all the data as is the rule now.  This isn't really something I have
> ever wanted to do.

Ok. The reason I wanted to do that is I have a lot of small (about 300 x 
300 pixels) adjacent map pieces of an area all in one projection. I 
"glue" those pieces together with ImageMagick montage program to form a 
larger map (typically something like 3000 x 3000 pixels) and then use 
gdalwarp (along with an ESRI world file) to warp it to another 
projection. Because I build the large maps by combining the small map 
pieces, I can have the large map pieces overlap each other a bit so 
removing the dark bands results in no image data loss from the view of 
the whole system.

> For your case I would just suggest you try cubic and bilinear, and 
> compare.  If you like the cubic better than the bilinear then use it 
> otherwise stick with bilinear.

I compared all four sampling algorithms available and I think I'll stick 
with nearest neighbor. The input images I'm using have an 8-bit color 
palette and the output of all other algorithms looks awful. I tried with 
the input images in RGB, but the file sizes get so huge that something 
goes wrong and gimp doesn't want to display the warped images anymore.. 
anyway I'm more than happy with the nearest neighbor resampling, just 
wondered whether it could be even better than that.

   Tapio1



More information about the Gdal-dev mailing list