saving all open figures in script as .png file in a folder
76 ビュー (過去 30 日間)
古いコメントを表示
working with image processing toolbox and trying to save all the figures as .png or .jpeg format in a specific folder using the code below:
FolderName = ('G:\Image proccessing\test'); % using my directory
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = num2str(get(FigHandle, 'Number'));
set(0, 'CurrentFigure', FigHandle);
saveas(FigHandle, strcat(FigName, '.png'));
end
there is no error but no image is saved.
0 件のコメント
回答 (1 件)
Voss
2022 年 3 月 29 日
It may be that the .png files are being saved in the current working directory (because FolderName (G:\Image proccessing\test) is not being used).
Try this instead:
FolderName = ('G:\Image proccessing\test'); % using my directory
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = num2str(get(FigHandle, 'Number'));
set(0, 'CurrentFigure', FigHandle);
% saveas(FigHandle, strcat(FigName, '.png'));
saveas(FigHandle, fullfile(FolderName,strcat(FigName, '.png'))); % specify the full path
end
2 件のコメント
Voss
2022 年 3 月 31 日
Verify that FigList contains all your figures, and possibly use the debugging utilities to figure out where the code is going wrong.
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!