Read multiple images from folder and subfolder within a for loop

1 visualizzazione (ultimi 30 giorni)
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

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by