[Image-SIG] bug in PIL rotate?

Mathieu Galtier mathieu.galtier at googlemail.com
Wed Sep 9 20:16:56 CEST 2009


Hello,

Ok it seems my first example is stupid. But have a look at this:

from scipy.misc import *
from pylab import *

n = 11
tab = zeros([n,n])
for i in range(n):
    tab[n/2,i] = 1.
matshow(tab)
for angle in range(8):
    angleDegre = angle * 180. / 8
    rotated = imrotate(tab,angleDegre,interp='bilinear') /255.
    matshow(rotated)
show()

knowing that imrotate is based on PIL's rotate.
There is a uneccessary translation.
No big deal: now I use: scipy.ndimage.interpolation.rotate

Bye bye.
Mathieu

Mathieu Galtier wrote:
> Hello,
>
> am I right to think that the rotate function of PIL 1.1.6 is broken?
>
> Try this simple example:
>
> import Image
> import numpy as np
> tab = np.random.rand(100).reshape(10,10)
> im = Image.fromarray(tab)
> assert(im == im.rotate(0))
>
> I went a bit further and it seems that rotate translates the image of 
> one pixel or so.
>
> Cheers
> Mathieu
>



More information about the Image-SIG mailing list