On 2/3/2011 6:50 PM, Eric Firing wrote:
On 02/03/2011 03:04 PM, Benjamin Root wrote:
Also, not to sound too annoying, but has anyone considered the idea of
using compressed arrays for holding those rgba values?
I don't see how that really helps; as far as I know, a full rgba array
has to be passed into agg. What *does* help is using uint8 from start
to finish. It might also be possible to use some smart downsampling
before generating the rgba array, but the uint8 route seems to me the
first thing to attack.
Eric
Ben Root
Please review the attached patch. It avoids generating and storing
float64 rgba arrays and uses uint8 rgba instead. That's a huge memory
saving and also faster. I can't see any side effects as
_image.fromarray() converts the float64 input to uint8 anyway.
So far other attempts to optimize memory usage were thwarted by
matplotlib's internal use of masked arrays. As mentioned before, users
can provide their own normalized rgba arrays to avoid all this processing.
Christoph
Index: image.py
===================================================================
--- image.py (revision 8944)
+++ image.py (working copy)
@@ -198,11 +198,11 @@
im.is_grayscale = False
else:
if self._rgbacache is None:
- x = self.to_rgba(self._A, self._alpha)
+ x = self.to_rgba(self._A, self._alpha, True)
self._rgbacache = x
else:
x = self._rgbacache
- im = _image.fromarray(x[yslice,xslice], 0)
+ im = _image.frombyte(x[yslice,xslice,:], 0)
if len(self._A.shape) == 2:
im.is_grayscale = self.cmap.is_gray()
else:
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users