matplotlib RuntimeError:无法为映像分配内存

时间:2012-06-14 21:37:33

标签: python memory-management matplotlib

因此,当我尝试在画布上重新调整图像大小时,我收到来自matplotlib的“RuntimeError:无法为图像分配内存”。图像是使用ctypes的PyMem_Malloc分配内存的大型DICOM(.dcm)文件。它们每像素分配16位(它们需要是高分辨率)。在我们重新调整画布大小并尝试使用以下方法绘制重新调整大小的图像之后出现问题:

self.view.canvas.draw()

以下是抛出的具体异常:

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_wx.py", line 1355, in _onMotion
    FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=evt)
  File "C:\Python27\lib\site-packages\matplotlib\backend_bases.py", line 1625, in motion_notify_event
    self.callbacks.process(s, event)
  File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 265, in process
    proxy(*args, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 191, in __call__
    return mtd(*args, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\widgets.py", line 1258, in onmove
    self.update()
  File "C:\Python27\lib\site-packages\matplotlib\widgets.py", line 1236, in update
    self.canvas.restore_region(self.background)
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", line 384, in restore_region
    renderer = self.get_renderer()
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", line 404, in get_renderer
    self.renderer = RendererAgg(w, h, self.figure.dpi)
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", line 59, in __init__
    self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
RuntimeError: Could not allocate memory for image

图像本身不需要更多分配,对吗?那么这里可能出现什么问题呢? matplotlib是否限制了画布可以容纳的内存大小?有人有这个问题吗?

0 个答案:

没有答案