フォルダから画像を順に読み取り処理する方法
Show older comments
画像が複数枚入っているフォルダを読み込み、順に処理を行って保存したいです。
下記のようなコードを書いているのですが、画像が全く表示されません。
エラーメッセージも出ないため、どこが間違っているのか特定できずにいます。
お力を貸していただけないでしょうか。
im_list=dir("フォルダ名");
file_name={im_list.name};
for i=3:size(file_name,1)
I=imread(file_name{1})
imshow(I)
I2=rgb2gray(I);
BW=I2<75;
imshow(BW)
saveas(fig,file_name{1}.pdf)
end
Accepted Answer
More Answers (1)
Shunichi Kusano
on 15 Jun 2022
Edited: Shunichi Kusano
on 15 Jun 2022
imageDatastore使うともっと簡単に書けてしまいます。おススメです。
imds = imageDatastore("フォルダ名");
while hasdata(imds)
[I,info] = read(imds);
% 処理を入れる
end
1 Comment
Categories
Find more on イメージ算術 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!