From 846e4209f9cfed3be669e5562a818f294e2bcd98 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 18 May 2017 20:36:20 +0100 Subject: [PATCH] fix rounding in region shrink we were not rounding int averages to nearest, thanks beaudet see https://github.com/jcupitt/libvips/issues/659 --- libvips/iofuncs/region.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index c0d32247..39b4626e 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -1149,7 +1149,7 @@ vips_region_shrink_labpack( VipsRegion *from, VipsRegion *to, VipsRect *target ) int b = sp[2] + sp[6] + sp[ls + 2] + sp[ls + 6]; - q[0] = l >> 2; + q[0] = (l + 2) >> 2; q[1] = a >> 2; q[2] = b >> 2; q[3] = 0; @@ -1170,7 +1170,7 @@ vips_region_shrink_labpack( VipsRegion *from, VipsRegion *to, VipsRect *target ) int tot = tp[z] + tp[z + nb] + \ tp1[z] + tp1[z + nb]; \ \ - tq[z] = tot >> 2; \ + tq[z] = (tot + 2) >> 2; \ } \ \ /* Move on two pels in input. \