フォルダから画像を順に読み取り処理する方法
显示 更早的评论
画像が複数枚入っているフォルダを読み込み、順に処理を行って保存したいです。
下記のようなコードを書いているのですが、画像が全く表示されません。
エラーメッセージも出ないため、どこが間違っているのか特定できずにいます。
お力を貸していただけないでしょうか。
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
采纳的回答
更多回答(1 个)
Shunichi Kusano
2022-6-15
编辑:Shunichi Kusano
2022-6-15
imageDatastore使うともっと簡単に書けてしまいます。おススメです。
imds = imageDatastore("フォルダ名");
while hasdata(imds)
[I,info] = read(imds);
% 処理を入れる
end
类别
在 帮助中心 和 File Exchange 中查找有关 イメージ算術 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!