Loading image files in the workspace from a folder

11 ビュー (過去 30 日間)
Nasir Holliday
Nasir Holliday 2020 年 11 月 3 日
回答済み: Sudhakar Shinde 2020 年 11 月 3 日
I have a Data folder that contains 50 jpg images. They are titled C1,C2,C3... up to C25 and N1,N2...N25. Is there one code to load all of the images into the workspace so I can call about them in future codes?
Thanks!

回答 (1 件)

Sudhakar Shinde
Sudhakar Shinde 2020 年 11 月 3 日
Check:
my_folder =pwd; %Folder path where images are present
PngFilenames=dir(fullfile(my_folder,'*.png'));
JpgFilenames=dir(fullfile(my_folder,'*.jpg'));
filenames = [PngFilenames;JpgFilenames];
Image = {};
for n = 1:numel(filenames)
fullname=fullfile(my_folder,filenames(n).name);
Image{end+1} = imread(fullname);
end

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by