How do I convert a figure directly into an image matrix in MATLAB 7.6 (R2008a)?
122 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2009 年 6 月 27 日
編集済み: MathWorks Support Team
2018 年 12 月 19 日
I have a figure with a plot created using the following code:
mesh(peaks(50));
I would like to convert the figure into an image within MATLAB without having to first print it to a file and read it back into MATLAB.
採用された回答
MathWorks Support Team
2018 年 12 月 19 日
A figure can be converted into an image using the GETFRAME and FRAME2IM functions in MATLAB. For example, the following code creates a snapshot of the current figure and writes it to an image in variable "X" with colormap stored in "Map":
F = getframe(gcf);
[X, Map] = frame2im(F);
If the frame contains true-color data, then "Map" will be an empty matrix.
For more information on the GETFRAME and FRAME2IM functions, consult the documentation by executing the following at the MATLAB prompt:
doc getframe
doc frame2im
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!