Greetings,
I searched the mail archive for information on this question, and
didn't find anything. Hopefully this hasn't been addressed elsewhere.
I just spent a few hours tracking down a huge performance hit in
imshow(). I'm loading some image data via numarray's fromfile(),
stacking three imgaes to make an RGB, and showing it with imshow.
My image loading code looks like this:
def read_dib(filename):
f = open(filename, "rb")
fromfile(f, "UInt8", shape=(52, 1))
im = fromfile(f, "UInt16", shape=(512, 512))
if sys.byteorder == "big":
im.byteswap()
return im.astype('Float') / (2**12 - 1)
I load three images, and put them into a NxMx3 float numarray, and
pass that to imshow.
The performance drop is at this line in image.py:
im = _image.fromarray(x, 0)
in AxesImage.make_image()
I eventually tracked it down to x's type being <class
'numarray.ma.MA.MaskedArray'>, which gets passed off to numarray's
NA_InputArray function, which chokes and calls setArrayFromSequence
(i.e., it's not using the fact that the input data is a numarray, and
is instead iterating over each element). This is taking around 30
seconds to convert a 512x512x3 image on a new Intel iMac.
I sped it up significantly by using this line instead:
im = _image.fromarray(numerix.ma.filled(x,0), 0)
Not that that's a good idea (but it works for me for now).
There is no invalid data in my image. I'm not sure why it's ever
being turned into a masked array.
I'm using matplotlib 0.86.2 and numarray-1.5.1, on OS X 10.3.5 on an Intel iMac.
Any advice would be appreciated.
Thanks,
Ray Jones