Read multiple images from folder and subfolder within a for loop

1 view (last 30 days)
Hi,
I intend to read image files placed inside folder (.jpg) and subfolder (.bmp) within a for loop opeartion. Could someone please help me out with this ??
for f = 1:1:1
if (f>=1) && (f<=9)
fname_strt = 'B0000' ;
elseif (f>=10) && (f<=99)
fname_strt='B000';
elseif (f>=100) && (f<=999)
fname_strt='B00';
else
fname_strt='B0';
end
fname_end = num2str(f);
fname = strcat(fname_strt,fname_end,'.jpg');
I=imread(fname);
G = imagesc(x,y,flipud(I));
G.AlphaData = 0.5;
hold on;
%%%%%%% Needs to be read from subfolder
if (f>=1) && (f<=9)
fname_strt = 'B0000' ;
elseif (f>=10) && (f<=99)
fname_strt='B000';
elseif (f>=100) && (f<=999)
fname_strt='B00';
else
fname_strt='B0';
end
fname_end = num2str(f);
fname = strcat(fname_strt,fname_end,'.jpg');
h=readimx(fname);
H1 = imagesc(flipud(h));
H1.AlphaData = 0.5;
axis equal
hold on;
end

Answers (0)

Categories

Find more on Loops and Conditional Statements 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!