Just imagine you plot several dots, circles, lines in a figure. Afterwards another m file should use this plot as an input to do e.g. thresholding. I'm aware of the print command but I don't want the plot to be stored as file. I would prefer to store it in a matrix (x_dim,y_dim,3). Any ideas?
Asked
Active
Viewed 9,462 times
2 Answers
2
You should check out the functions getframe
and frame2im
to convert a figure or axes object to an image matrix.

gnovice
- 125,304
- 15
- 256
- 359
-
GETFRAME & FRAME2IM look like that they provide the functionality I was looking for. Unfortunately the grabbed resolution is extremely bad. Original image size where I did the plot is 2048x4096. After GETFRAME and FRAME2IM resolution is down to 513x1025! Any idea why? – Josef St. Jul 15 '10 at 07:39
-
@Josef St.: The function GETFRAME captures what you see on the screen in the figure window. If you plot an image (using, say, the IMAGE command), then the image may be scaled down to fit the figure window, and when the figure window is captured by GETFRAME you end up with a smaller image than before. You should check out these related SO questions: http://stackoverflow.com/questions/1848176/how-do-i-save-a-plotted-image-and-maintain-the-original-image-size-in-matlab, http://stackoverflow.com/questions/575475/how-can-i-save-an-altered-image-in-matlab – gnovice Jul 15 '10 at 15:34
0
How about save to an image?
You can use getframe
to get a frame object F, where F.cdata contains the RGB values.
Remember to use 'border', 'tight'
option to avoid capturing the borders.

Ivan Xiao
- 1,919
- 3
- 19
- 30