MATLAB Answers

read .png from different subfolder

13 views (last 30 days)
Niki
Niki on 26 Feb 2014
Edited: Azzi Abdelmalek on 26 Feb 2014
I have a folder with a lot of subfolders. I want to read all .png in one subfolder and save and then go to the second subfolder and read all the .png and save and then go to the third subfolder etc. anyone can help me with it?

  0 Comments

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 26 Feb 2014
See my attached demo to recurse into subfolders.

  0 Comments

Sign in to comment.


Azzi Abdelmalek
Azzi Abdelmalek on 26 Feb 2014
Edited: Azzi Abdelmalek on 26 Feb 2014
folder='E:\matlab'
d=dir(folder)
subf=d([d.isdir])
im=[]
for k=3:numel(subf)
subfolder=subf(k).name
subf1=fullfile(folder,subfolder)
f=dir([subf1 '\*.png'])
for ii=1:numel(f)
file=fullfile(subf1,f(ii).name);
im{end+1}=imread(file);
end
end
im

  0 Comments

Sign in to comment.


Translated by