Accessing Image Files from Multiple Folders

3 views (last 30 days)
Hello All,
I'm having difficulty reading images from multiple folders and running the same code on all of them. Suppose my image directory is
dir ('C:\...exp03\data');
And the 'data' folder have folders data01, data02 etc.. where each folder would have images 01_01.jpg, 01_02.jpg (from data01 folder) and 02_01.jpg, 02_02.jpg (from data02 folder) etc.
So far I have the following code which runs for 1 folder.
fileNames = dir(fullfile('C:\...\data01','*.jpg'));
N = length(fileNames);
for k = 1:N
filename = fileNames(k).name;
C{k} = imread(filename);
end
How do I modify so that I can read the images from all image folders? Please help.
Thank You

Accepted Answer

Image Analyst
Image Analyst on 4 Nov 2013
See my demo attached below.
  4 Comments
Image Analyst
Image Analyst on 5 Nov 2013
Just put in an imread() or imshow() or something like that.

Sign in to comment.

More Answers (0)

Categories

Find more on File Operations 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!