how to save the content of the current figure as an image?
이전 댓글 표시
how to save the content(which is an image) of the current figure as an image?
I have about 30 figure ...
I want to use MATLAB commands to save them in for loop
채택된 답변
추가 답변 (3개)
Francesco Ciriello
2019년 11월 20일
Save current figure
imwrite(getframe(gcf).cdata, 'myfilename.png')
Save current axis
imwrite(getframe(gca).cdata, 'myfilename.png')
댓글 수: 1
Raviteja Vangara
2020년 5월 12일
I think this deserves an upvote. I have an image with alpha data, and traditional saveas options wouldnt store alpha data in saved PNG file.
using,
H = getframe(gca)
imwrite(H.cdata, 'myfilename.png')
This saves current figure as it appears on the window.
Image Analyst
2014년 9월 18일
0 개 추천
Use imwrite() if you just want to save the image you display. If you want to save the axes or figure, use export_fig(). http://matlab.wikia.com/wiki/FAQ#How_do_I_save_my_figure.2C_axes.2C_or_image.3F_I.27m_having_trouble_with_the_built_in_MATLAB_functions.
댓글 수: 2
Nisreen Sulayman
2014년 9월 19일
편집: Nisreen Sulayman
2014년 9월 19일
Image Analyst
2014년 9월 19일
Just use fullfile() when you construct the file name that you pass in to export_fig().
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!