better rounding behaviour for bicubic

fixed-point bicubic was not rounding to nearest, introducing some noise
in flat areas
This commit is contained in:
John Cupitt 2014-08-05 10:02:11 +01:00
parent e4996d8dce
commit ebeee822bc
3 changed files with 12 additions and 11 deletions

View File

@ -7,6 +7,7 @@
- pngsave in interlaced mode make a copy of the whole image - pngsave in interlaced mode make a copy of the whole image
- vipsthumbnail shrinks to 1/2 window_size - vipsthumbnail shrinks to 1/2 window_size
- vipsthumbnail defaults to bicubic + nosharpen - vipsthumbnail defaults to bicubic + nosharpen
- better rounding behaviour for fixed-point bicubic
4/7/14 started 7.40.4 4/7/14 started 7.40.4
- fix vips_rawsave_fd(), thanks aferrero2707 - fix vips_rawsave_fd(), thanks aferrero2707

7
TODO
View File

@ -6,12 +6,7 @@
$ vipsthumbnail Chicago.png --vips-concurrency=4 $ vipsthumbnail Chicago.png --vips-concurrency=4
memory: high-water mark 180.57 MB memory: high-water mark 180.57 MB
shouldn't memuse drop with concurrency 1? shouldn't memuse drop with concurrency 1 ?
- bicubic adds noise to 255/255/255, why? try babe.jpg background

View File

@ -183,30 +183,35 @@ bicubic_int(
(cx[0] * uno_one + (cx[0] * uno_one +
cx[1] * uno_two + cx[1] * uno_two +
cx[2] * uno_thr + cx[2] * uno_thr +
cx[3] * uno_fou) >> VIPS_INTERPOLATE_SHIFT; cx[3] * uno_fou +
(VIPS_INTERPOLATE_SCALE >> 1)) >> VIPS_INTERPOLATE_SHIFT;
const int r1 = const int r1 =
(cx[0] * dos_one + (cx[0] * dos_one +
cx[1] * dos_two + cx[1] * dos_two +
cx[2] * dos_thr + cx[2] * dos_thr +
cx[3] * dos_fou) >> VIPS_INTERPOLATE_SHIFT; cx[3] * dos_fou +
(VIPS_INTERPOLATE_SCALE >> 1)) >> VIPS_INTERPOLATE_SHIFT;
const int r2 = const int r2 =
(cx[0] * tre_one + (cx[0] * tre_one +
cx[1] * tre_two + cx[1] * tre_two +
cx[2] * tre_thr + cx[2] * tre_thr +
cx[3] * tre_fou) >> VIPS_INTERPOLATE_SHIFT; cx[3] * tre_fou +
(VIPS_INTERPOLATE_SCALE >> 1)) >> VIPS_INTERPOLATE_SHIFT;
const int r3 = const int r3 =
(cx[0] * qua_one + (cx[0] * qua_one +
cx[1] * qua_two + cx[1] * qua_two +
cx[2] * qua_thr + cx[2] * qua_thr +
cx[3] * qua_fou) >> VIPS_INTERPOLATE_SHIFT; cx[3] * qua_fou +
(VIPS_INTERPOLATE_SCALE >> 1)) >> VIPS_INTERPOLATE_SHIFT;
return( (cy[0] * r0 + return( (cy[0] * r0 +
cy[1] * r1 + cy[1] * r1 +
cy[2] * r2 + cy[2] * r2 +
cy[3] * r3) >> VIPS_INTERPOLATE_SHIFT ); cy[3] * r3 +
(VIPS_INTERPOLATE_SCALE >> 1)) >> VIPS_INTERPOLATE_SHIFT );
} }
/* Floating-point bicubic, used for int/float/double types. /* Floating-point bicubic, used for int/float/double types.