Big slowdown showing PNG images

Hello.

I had a piece of code working perfectly fine with matplotlib 0.87.2.
Now I updated to 0.87.3 and it is about 100 times slower (!).

The code shows a PNG image using axes.imshow.

<code>

from pylab import *
from time import asctime, time
import Image

PNG_file='foo.png'
fh=figure()
ax = fh.add_subplot(111)
print 'Image intepolation = %s' % rcParams['image.interpolation']
print 'Image aspect = %s' % rcParams['image.aspect']
print 'Date/Time = %s' % asctime()
t1=time()

print "Starting Image.open"
image = Image.open(PNG_file)
print "Image.open terminated"

print "Starting imshow"
ax.imshow(image, origin='lower')
print "imshow terminated"

setp(ax.get_xticklabels(), visible=False)
setp(ax.get_yticklabels(), visible=False)
setp(ax.get_xticklines(), visible=False)
setp(ax.get_yticklines(), visible=False)
t2=time()
print 'Execution time [s] = %4.2f' % (t2-t1)
show()

</code>

I tried to create a patch but couldn't understand internal details of
matplotlib, so here are the directions:

1 - The offending part is imshow. (not PIL Image.open)
2 - 0.87.3 imshow has some new code:
<code>
        if vmin is not None or vmax is not None:
            im.set_clim(vmin, vmax)
        else:
            im.autoscale()
</code>

As I do not call imshow with vmax neither vmin this will always fall
into the else clause and call im.autoscale, that is the offending part
on axes.imshow.

Commenting im.autoscale() call makes it fast again, but i don't know
if this is right.

My image is 25K and 2400x1800 black and white PNG. I can send it...

I tried using aspect as 'normal', 'equal' and 'auto' but none had
performance as good as mpl 0.87.2.

Matplotlib 0.87.2 showed figure in less than 0.5 sec, 0.87.3 in about 45 sec.

Should I file a bug report?

···

--
Regards
Leandro Lameiro

Blog: http://lameiro.redirectme.net/blog