[GRASS-dev] bilinear and bicubic raster interpolation

Glynn Clements glynn at gclements.plus.com
Sun Oct 17 05:06:23 EDT 2010


Markus Metz wrote:

> In i.rectify, I have implemented the interpolation methods available
> in r.proj, and while testing discovered an offset of one cell (row +
> 1, col + 1 from source to target) between the source and target
> imagery after rectifying (40+ automatically collected GCPs, order=1,
> sub-pixel RMS errors, source image not distorted). I corrected this
> offset in i.rectify and suggest that all modules using
> Rast_interp_linear/Rast_interp_bilinear/Rast_interp_cubic/Rast_interp_bicubic
> should be checked. I am pretty sure that at least r.proj needs this
> fix (if a one-cell shift is something to worry about).

Actually, I think that r.proj[.seg] have half-cell errors, i.e. they
treat a cell's value as a sample at its north-west corner rather than
its centre. A test case with r.proj (7.0) appears to confirm this. 
This applies to both bilinear and bicubic interpolation.

A column coordinate of e.g. 7.3 should interpolate between sample
values at 6.5 and 7.5 with an interpolation parameter of 0.8. This
uses cells 6 and 7 for bilinear interpolation and cells 5,6,7,8 for
bicubic interpolation.

This should be fixed by r43943.

However, there is another issue with r.proj (7.0) and r.proj.seg
(6.x): bilinear and cubic interpolation give a small number of garbage
results due to incorrect use of the caching mechanism (blocks are
being replaced while references remain). I'll fix this shortly.

In the linear and 

> I think this kind of correction is also done in r.resamp.interp.

r.resamp.interp and Rast_get_sample_* appear to be correct.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list