0

I am using version R2007a.

First for a little background: I am creating a tool that accumulates a scatter plot from data acquired in real time. When the number of points gets large enough, the graphics refresh can't keep up with the incoming data, so I am using 'painters' with 'EraseMode' set to 'none' and simply doing a set(obj,'xdata',...,'ydata',...) to update the plot point position. This works very nicely.

Incidentally, I discovered a nice trick: by turning on double buffering, MATLAB always has a copy of the image in memory, so points accumulate in the image even when the window is hidden or minimized!

Now I would like to capture each image to create a movie. I have seen a variety of solutions using getframe(), addframe(), and the undocumented hardcopy(). These all redraw the figure and the old points are lost, but this is actually something I can work around in post-processing. My issue is that these functions are too slow for the data acquisition rate. With tic/toc, I find

tic, getframe(h); toc - 0.13 sec
tic, addframe(h); toc - 0.15 sec
tic, hardcopy(h,'-Dpainters','r0'); toc - 0.07 sec

I see that hardcopy() does something different with 'renderer' set to 'painters', but even if I could find out how to make of use of its output, it's still too slow.

But with double buffering on, the image is already sitting in the backing store / back buffer. Making a copy of that would be quite fast. Can any hackers out there figure out how to get a pointer to the backing store and make a copy of it?

Thanks

wakjah
  • 4,541
  • 1
  • 18
  • 23
  • Why don't you just store the incoming real-time data in a file, play it back later (plot each frame) and make a video out of that, rather than trying to create the video in real-time as well? – wakjah Jun 02 '13 at 09:42
  • 1
    Also, you may find [this question](http://stackoverflow.com/questions/8862467/using-opengl-in-matlab-to-get-depth-buffer) interesting, as it has a method of accessing the figure's pixels directly when the OpenGL renderer is used. – wakjah Jun 02 '13 at 10:01
  • I have a similar question: http://stackoverflow.com/questions/30071607/matlab-using-the-gpu-for-saving-an-image-off-a-figure What do you mean by " turning on double buffering"? – Uri Cohen May 06 '15 at 16:13
  • It seems that hardcopy (and all other methods) re-render the figure. – Uri Cohen May 06 '15 at 18:02

0 Answers0