Saving images in .FIG format from a source code

Hello everyone!
I have a code that shows me figures with the imshow(outpict) command where "outpict" is shown in the following image (along with other parameters):
I would like to save all the figures shown with imshow(outpict) in the .FIG format in a folder other than the working folder.
In the above image10 images have been opened (parameter k) and each is shown with imshow(outpict).
I thank you if you can help me out.

2 件のコメント

DGM
DGM 2022 年 10 月 29 日
編集済み: DGM 2022 年 10 月 30 日
I know I already posted my thoughts on this matter in an answer to your other question, but...
% ... code that does stuff
for k = 1:numberofimages
% ... code that does stuff
% at some point you have an output image
outpict = something(thatdoesstuff);
% you can display it if you want, but that's just for visualization
imshow(outpict)
% if you want to save it, you can use imwrite()
% if you want, you can automatically number the files like so
imwrite(outpict, sprintf('myoutput_%04d.png',k))
end
Alberto Acri
Alberto Acri 2022 年 10 月 30 日
Thank you @DGM! That's just what I needed!

サインインしてコメントする。

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 10 月 29 日
編集済み: KALYAN ACHARJYA 2022 年 10 月 29 日

0 投票

for loop i=
figure,imshow(Image_file)
file_name=['image',num2str(i),'.fig']
savefig(gcf,file_name); % Set an other folder path/directory
close all
end
#To set the folder path, yoo can refer your earlier question.
Hope it Helps!
Walter Roberson
Walter Roberson 2022 年 10 月 29 日

0 投票

Use fullfile(FolderToSaveInto, FileNameToSaveTo) in order to construct the output file name. For example,
savedir = '../saved_results';
file_name = fullfile( savedir, sprintf('myoutput_%04d.fig',k) );
savefig(gcf, file_name)

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

製品

リリース

R2021b

質問済み:

2022 年 10 月 29 日

コメント済み:

2022 年 10 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by