[Gdal-dev] Resampling with gdalwarp

Lowell Johnson ldjohn at usgs.gov
Wed Mar 17 12:06:44 EST 2004


On Wednesday 17 March 2004 12:40 am, Frank Warmerdam wrote:
[snip]
> I don't know what the formal definition of "bilinear resampling" is. 
> I suspect that name can apply to a variety of techniques.  Let me
> explain what GDAL does.
>
> 1) It takes the center point of the output pixel, and geometrically
> transforms it to a location on the input pixel (with subpixel
> resolution).
>
> 2) The four pixels closest to the input sampling location are used in
> the kernel, and the proximity of the sampling location to the center
> of each input pixel determines it's contribution in a bilinear
> fashion.

Yes, this sounds like the definition of bilinear resampling that I'm 
familiar with.  Here's a quick illustration (use fixed fonts to get 
ASCII image to display properly):

  o     = projection input location of output pixel center
  d1-d4 = 4 input pixel DN values
  px,py = input pixel dimensions
  dx,dy = line, sample offset of 'o' from first pixel center
  DN    = bilinear resampled DN for 'o'

                           |  px   |
                         dx| |     |
                       +-------+-------+
                       |   d1  |   d2  |   2x2 input space pixels
                  -----|   +   |   +   |
                   dy--|     o |       |
                  py   +-------+-------+
                       |   d3  |   d4  |
                  -----|   +   |   +   |
                       |       |       |
                       +-------+-------+

  Let u = dx/px, v = dy/py.

  DN = d1*(1 - u)*(1 - v) + d2*u*(1 - v) + d3*(1 - u)*v + d4*u*v

> Some implications to note:
[snip remainder]

I agree with Frank's comments regarding the (mis)use of bilinear 
resampling for downsampling, at least by my definition of "bilinear 
resampling". :)  Some sort of averaging does sound like a better method 
although I haven't much experience with image scaling issues.

    Lowell




More information about the Gdal-dev mailing list