MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   在内存中渲染MATLAB图形 (https://www.labfans.com/bbs/showthread.php?t=24093)

poster 2019-12-10 20:48

在内存中渲染MATLAB图形
 
除了使用getframe和saveas将图形内容保存到光栅图像以进行进一步处理之外,还有其他选择吗?

[B]方法1: getframe[/B]

h = figure('visible', 'off'); a = axes('parent', h); % render using `scatter3()` or other plot function. content = frame2im(getframe(h)); 这具有严重的缺点,即在调用getframe()时显示该图形以执行屏幕捕获,并且在循环中执行此类渲染时会出现问题(即,将每次迭代中的content另存为视频帧)。

[B]方法2: saveas[/B]

h = figure('visible', 'off'); a = axes('parent', h); % render using `scatter3()` or other plot function. saveas(h, '/path/to/file.png'); content = imread(/path/to/file.png'); 这种方法的严重缺陷是写入磁盘,这在多线程应用程序中是有问题的,并且比直接渲染到内存要慢。由于saveas()显然会在调用PNG编码器之前渲染到内存,因此我可以实现所需的功能,但是我在仅执行渲染部分的MATLAB文档中找不到任何功能。

[B]问题[/B] :

您是否知道将任意axes内容呈现到栅格图像的另一种方法?



[B]回答:[/B]

如果创建一个AVI文件avifile ,然后添加帧将其与addframe ,喜欢与不MATLAB开不起来的额外可见人物getframe 。

avi = avifile('/path/to/output'); figure_handle = figure('visible', 'off'); % ... for something = 1:1000 cla % (draw stuff...) avi = addframe(avi, figure_handle); end

[url=https://stackoverflow.com/questions/4137628]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:25

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.