Hi all, I think there is a bug in the nearest neighbour resizing filter: when resizing an image with an integer ratio, the original pixels are not all expanded by this ratio. For example:
>>> from PIL import Image >>> Image.VERSION '1.1.7' >>> im = Image.open("input.png") >>> for x in range(0, 6): ... im.getpixel((x, 0)) ... (255, 0, 0) (0, 255, 0) (0, 0, 255) (255, 0, 0) (0, 255, 0) (0, 0, 255) The first column of my input image is RGBRGB... >>> zim = im.resize((im.size[0] * 3, im.size[0] * 3), Image.NEAREST) >>> for x in range(0, 18): ... zim.getpixel((x, 0)) ... (255, 0, 0) (255, 0, 0) (255, 0, 0) (0, 255, 0) (0, 255, 0) (0, 255, 0) (0, 255, 0) (0, 0, 255) (0, 0, 255) (255, 0, 0) (255, 0, 0) (255, 0, 0) (0, 255, 0) (0, 255, 0) (0, 255, 0) (0, 255, 0) (0, 0, 255) (0, 0, 255) Note that the first pixel is repeated 3 times, the second 4 times, then 2, 3, 4, amd 2 times. I would expect each pixel to be repeated 3 times, and I think that is what "nearest neighbour" means. I could track the bug down to libImaging/Geometry.c, function ImagingScaleAffine(), lines 672-697. there must be something wrong in these two loops, probably related to the integer rounding, but I wasn't able to figure out the exact meaning of all the variables. -- Nicolas LIMARE - CMLA - ENS Cachan http://www.cmla.ens-cachan.fr/~limare/ IPOL - image processing on line http://www.ipol.im/
signature.asc
Description: Digital signature
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig