NN now rounds down rather than to nearest

nearest-neighbour interpolation now strictly rounds down rather than
rounding to nearest

round to nearest caused strange half-pixels along top/left image edges
during enlargement, and extra 1.5 sized pixels everywhere else

instead we should fix the thing that round to nearest was supposed to fix by
adding an extra pair of params to the affine transform which displace in
input space (dx/dy displace in output space)
This commit is contained in:
John Cupitt 2012-11-30 21:35:12 +00:00
parent 20ce700e23
commit 6f22c00df4
3 changed files with 9 additions and 4 deletions

View File

@ -22,6 +22,8 @@
- vipsthumbnail -o allows absolute file names
- much better exif handling for jpg images (thanks Gary)
- preserve jpeg app13 (photoshop ipct)
- nearest neighbour goes back to round down ... round to nearest caused a
range of annoying problems, such as strange half-pixels along edges
14/11/12 started 7.30.6
- capture tiff warnings earlier

5
TODO
View File

@ -1,3 +1,8 @@
- now we've removed round-to-nearest from NN, we need something extra in the
affine transform to displace the input cods
dx/dy displace output
- check libtool version number, should be binary-compat with 7.30
- quadratic doesn't work for order 3

View File

@ -333,10 +333,8 @@ vips_interpolate_nearest_interpolate( VipsInterpolate *interpolate,
{
const int ps = IM_IMAGE_SIZEOF_PEL( in->im );
/* We know x/y are always positive, so we can just (int) them.
*/
const int xi = (int) (x + 0.5);
const int yi = (int) (y + 0.5);
const int xi = (int) x;
const int yi = (int) y;
const VipsPel *p = IM_REGION_ADDR( in, xi, yi );
VipsPel *q = (VipsPel *) out;