[Image-SIG] downscaling by area averaging
Fredrik Lundh
fredrik at pythonware.com
Sat May 7 12:29:07 CEST 2005
Douglas Bagnall wrote:
> > + I'm beginning to wonder if there's not an off-by-something error
> > lurking somewhere in stretch. hmm...
>
> In my tests, all the resize and stretch filters appear to shift the
> image down and to the right by about half an output pixel. Assuming
> my controls images are right...
I've attached a (preliminary) patch.
</F>
Index: libImaging/Antialias.c
===================================================================
--- libImaging/Antialias.c (revision 2394)
+++ libImaging/Antialias.c (working copy)
@@ -145,7 +145,7 @@
if (imIn->xsize == imOut->xsize) {
/* vertical stretch */
for (yy = 0; yy < imOut->ysize; yy++) {
- center = yy * scale;
+ center = (yy + 0.5) * scale;
ww = 0.0;
ss = 1.0 / filterscale;
/* calculate filter weights */
@@ -222,7 +222,7 @@
} else {
/* horizontal stretch */
for (xx = 0; xx < imOut->xsize; xx++) {
- center = xx * scale;
+ center = (xx + 0.5) * scale;
ww = 0.0;
ss = 1.0 / filterscale;
xmin = floor(center - support);
More information about the Image-SIG
mailing list