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

Tapio Sokura oh2kku at iki.fi
Thu Jan 6 16:13:18 EST 2005


Hi,

I'm a newbie with GDAL. So far I have managed to successfully use 
gdalwarp to transform raster images from one projection to another. As 
the target projection is different from the source, dark bands form to 
the edges to keep the image rectangle shaped. Is there an easy way to 
make gdalwarp automatically crop the map so that all the dark bands are 
removed, naturally with some inage data being cut out near the edges?

I've looked at the gdalwarp manual page and the switch to do that didn't 
jump up to my eyes. I see there is the -te parameter I can use to 
specify the extents of the new image. It works, but to use it I need to 
convert the image first and then manually find out the maximum map 
extents that result in a map with no dark edges. Is there an automatic 
way to do this?

A second thing came to mind on an optimal amount of pixels for the 
transformed image. Is there a rule of thumb or a simple algorithm to 
calculate the optimal amount of pixels to specify for -ts if I wanted 
the resulting image to look as good as possible without spending pixels 
on nothing? For now I've used the pixel count of the original picture as 
a starting point and increased the amount by about as many pixels as the 
dark map edges occupy in the final image.

And about the resampling algorithm. Is there a rule of thumb on which 
algorithm to use when the goal is to just change the projection and not 
significantly change the amount of pixels in the image? So far I have 
used the nearest neighbor algorithm. CPU usage (more complex algorithms) 
is not a problem. The images I've been transforming have been man-made 
maps with some 10-20 colors and anti-aliased lines.

Thanks,
   Tapio



More information about the Gdal-dev mailing list