SourceForge logo
SourceForge logo
Menu

Re: [Matplotlib-users] imshow size limitations?

From: Eric F. <ef...@ha...> - 2008年09月06日 20:10:05
David Goldsmith wrote:
> Hi! I'm trying to display a 10800 x 8100 pixel image w/ imshow using the following code (adapted from a response to a previous post of mine):
> 
> from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
> from matplotlib.figure import Figure
> 
> fig = Figure(figsize=(36,27), 
> dpi=300, 
> frameon=False)
> canvas = FigureCanvas(fig)
> ax = fig.add_subplot(111, xticks=[], yticks=[])
> cmap = MPL.cm.get_cmap('prism_r')
> ax.imshow(result, cmap=cmap)
> canvas.print_figure('HiResHex')
> 
> I get the following error report:
> 
> Traceback (most recent call last):
> File "Hex.py", line 208, in <module>
> canvas.print_figure('HiResHex')
> File "C:\python25\lib\site-packages\matplotlib\backend_bases.py", line 1201, i
> n print_figure
> self.figure.canvas.draw()
> File "C:\python25\lib\site-packages\matplotlib\backends\backend_agg.py", line
> 358, in draw
> self.figure.draw(self.renderer)
> File "C:\python25\lib\site-packages\matplotlib\figure.py", line 624, in draw
> for a in self.axes: a.draw(renderer)
> File "C:\python25\lib\site-packages\matplotlib\axes.py", line 1305, in draw
> for im in self.images if im.get_visible()]
> File "C:\python25\lib\site-packages\matplotlib\image.py", line 131, in make_im
> age
> x = self.to_rgba(self._A, self._alpha)
> File "C:\python25\lib\site-packages\matplotlib\cm.py", line 75, in to_rgba
> x = self.norm(x)
> File "C:\python25\lib\site-packages\matplotlib\colors.py", line 593, in __call
> __
> val = ma.asarray(value).astype(npy.float)
> File "C:\python25\lib\site-packages\numpy\core\ma.py", line 1151, in astype
> d = self._data.astype(tc)
> MemoryError
> 
> Is there some maximum number of pixels imshow can handle? Any other suggestions?
David,
It looks to me like you simply ran out of memory--this is not an imshow 
problem as such. Your array is about 1e8 elements, and as floats that 
would be close to a GB--just for that array alone. Do you really need 
all that resolution? If you do, you will probably have to get a much 
more capable machine. Otherwise, you need to knock down the size of 
that array before trying to plot or otherwise manipulate it.
With respect to imshow, probably you can get it to handle larger images 
if you feed them in as NxMx4 numpy.uint8 RGBA arrays--but I doubt this 
is going to be enough, or the right approach, for your present situation.
Eric
> 
> Platform Details: MPL 0.91.2 (sorry, I didn't realize I was running such an old version, maybe I just need to upgrade?), Python 2.5.2, Windows XP 2002 SP3, 504MB physical RAM, 1294MB VM Page size (1000MB init., 5000MB max)
> 
> Thanks!
> 
> DG

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /