Hi everyone. I resized an 8x16 RGB image to 4x8 using PIL (1.1.6). I used the bilinear filter. The results were not exactly as I had expected.
I performed the same operation using The Gimp (2.4.2), and sure enough, the result was quite different, and fit my understanding of a bilinear filter. See attached images. There seem to be two difference, one significant (for my application), and one a minor implementation detail. 1) Each pixel in The Gimp's output image can be determined by summing the pixels in each 2x2 block starting from the top left hand corner and dividing by four. This fits my understanding of a bilinear filter. I don't understand how PIL arrives at its result. 2) PIL appears to use pure integer division to average the 2x2 blocks, resulting in truncation. By contrast, Gimp's filter seems to use fractional math and round to the nearest value. I examined the resize function in the Image class, but stopped when I realised that it calls a function from the compiled imaging core library. This is my first adventure with PIL. Please forgive the attachments, but they are very small. Bruce.
<<attachment: original.png>>
<<attachment: pil_resize_linear.png>>
<<attachment: gimp_resize_linear.png>>
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig