フィルターのクリア

reading image files in a sequence

2 ビュー (過去 30 日間)
navin chandra
navin chandra 2019 年 2 月 23 日
回答済み: Geoff Hayes 2019 年 2 月 23 日
I have 20 images with file name "single_part001" , "single_part002" and so on. I want to read those files with variable name as I1, I2, I3... I20. How can I do that?

回答 (1 件)

Geoff Hayes
Geoff Hayes 2019 年 2 月 23 日
navin - don't create variables dynamically (which is what you intend to do with variables names l1, l2, l3, ...). See Stephen's post at TUTORIAL: Why Variables Should Not Be Named Dynamically (eval) to understand why this might not be a great idea. Instead, load the images into a cell array.
myImages = cell(20,1);
pathToImages = '/Users/yourname/whatever'; % the path to the folder of images
for k = 1:20
filename = sprintf('single_part%03d.png', k); % or whatever extension for your image
myImages{k,1} = imread(fullfile(pathToImages, filename));
end

カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by