python 含子图的gif生成时内存溢出的方法
作者:睡觉不准打呼噜 时间:2022-11-30 05:33:12
今天想用python做个demo,含两个子图的动态gif,代码如下:
import matplotlib.pyplot as plt
import imageio,os
import matplotlib
# plt.ion()
fig=plt.figure(0)
ax1=plt.subplot(121)
ax2=plt.subplot(122)
ax1.set_title('input')
ax2.set_title('GT')
for i in range(1000):
img1=plt.imread('F:\\pythonprogram\\test_bord/path\\enc_in_img\\{}.png'.format(i))
img2 = plt.imread('F:\\pythonprogram\\test_bord/path\\dec_out_img\\{}.png'.format(i))
ax1.imshow(img1)
ax2.imshow(img2)
# ax2.axis('off')
plt.pause(0.00001)
plt.cla()
plt.show()
首先分别将画布分为两块,分别循环读如图片,显示图片后暂停,再清除原图像~
但是由于plt.cla()只能作用于最后一个子图,第一块子图读取过程中占用大量内存导致内存溢出,目前没找到解决办法。
最后在matlab上完成这个工作。
来源:https://blog.csdn.net/shuijiaobuzhundahulu/article/details/92799495
标签:python,gif,内存,溢出
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python 一句话生成字母表的方法
2022-03-15 06:49:47
Python必须了解的35个关键词
2023-05-20 07:37:33
SQL Server可写脚本和编程扩展SSIS包
2009-01-20 16:29:00
Mysql如何实现不存在则插入,存在则更新
2024-01-26 11:13:54
![](https://img.aspxhome.com/file/2023/3/118473_0s.png)
Python制作一个仿QQ办公版的图形登录界面
2021-06-23 20:08:49
![](https://img.aspxhome.com/file/2023/1/101611_0s.png)
详细解读php的命名空间(一)
2023-06-19 08:02:59
如何通过神经网络实现线性回归的拟合
2023-04-24 06:15:07
![](https://img.aspxhome.com/file/2023/7/64267_0s.jpg)
vscode怎么编译运行
2022-12-12 13:52:07
![](https://img.aspxhome.com/file/2023/3/132253_0s.png)
Bootstrap Paginator分页插件使用方法详解
2023-09-05 23:08:42
![](https://img.aspxhome.com/file/2023/4/56294_0s.png)
数据结构简明备忘录 线性表
2024-01-25 01:59:28
![](https://img.aspxhome.com/file/2023/3/104103_0s.jpg)
Tesserocr库的正确安装方式
2023-12-26 17:19:34
![](https://img.aspxhome.com/file/2023/3/124363_0s.png)
关于代码阅读问题的小技巧 脚本之家原创(适合所有网站)不定时更新
2024-01-04 14:57:42
YOLOv5车牌识别实战教程(二)理论基础
2021-11-08 09:16:06
![](https://img.aspxhome.com/file/2023/1/131261_0s.png)
Python实现的计数排序算法示例
2022-07-27 15:03:55
![](https://img.aspxhome.com/file/2023/6/130776_0s.png)
解决Python报错:SyntaxError: invalid character ‘,‘ (U+FF0C)
2023-01-24 06:12:57
![](https://img.aspxhome.com/file/2023/5/124215_0s.png)
Django中create和save方法的不同
2021-06-16 14:24:02
scrapy-splash简单使用详解
2023-06-02 15:22:37
![](https://img.aspxhome.com/file/2023/1/103161_0s.jpg)
sql语句查询数据库中的表名/列名/主键/自动增长值实例
2024-01-22 16:53:53
Python实现批量下载ts文件并合并为mp4
2022-07-15 20:24:09
![](https://img.aspxhome.com/file/2023/0/70110_0s.png)
在系统崩溃的时候如何恢复原有的数据
2009-01-08 13:26:00