Read multiple images from folder and subfolder within a for loop

1 次查看(过去 30 天)
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by