getframe + frame2im + imwrite - Save figure
16 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone. I'd like to save a figure using statements getframe+frame2im+imwrite (without print statement). Is it possible to do it? I wrote the following code:
close all
clear all
t=[0:0.1:10];
x=t;
plot(t,x)
f=getframe(gcf);
[X,Map]=frame2im(f);
a=imwrite(X,'Figura 1.jpg')
but there is the error:
Error using imwrite Too many output arguments.
Error in Untitled2 (line 8) a=imwrite(X,'Figura 1.jpg')
Thank you very much.
0 件のコメント
回答 (2 件)
Walter Roberson
2017 年 6 月 26 日
imwrite() has no outputs. It just creates the file. If for some reason you want to load the content of the file back in to compare to the data in X that you wrote out, then use imread() on the file.
Note: .jpg files will rarely compare exactly equal to the original data, because JPEG loses information as it compresses data.
2 件のコメント
Image Analyst
2017 年 6 月 27 日
Why are you doing all that? If you just want to save your axes as a picture file, use saveas(), or better yet, export_fig().
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!