Reputation: 11
I have a folder(Enroll) which contain 100 or more sub folders and each of them contain one image. I want to read this image and do some processing on this image. I have problem with how to read them from the different folders ?
note * ( the sub folders name is number like : 1, 2,.. " this number arrived from user " ) (the image name is number but different and not sequential like : 433535.bmp , 126554,bmp ,...)
foldername=1; // name of the sub folder arrived from user
d4= dir('C:\Users\Sarah\Desktop\Log\Log\Enroll\',foldername,'\*.bmp');// here problem when i put foldername variable
foldername2=d4(1).name;
w=imread(fullfile('C:\Users\Sarah\Desktop\Log\Log\Enroll\',foldername,'\*.bmp', foldername2));
help me please :(
Upvotes: 1
Views: 99
Reputation: 35525
foldername
is not a string. therefore, you need to make it a string. I believe that what you want is
d4= dir(['C:\Users\Sarah\Desktop\Log\Log\Enroll\' num2str(foldername) '\*.bmp']);
Note:
1- you need to convert from number to string whatever number you have. If foldername
is a string, then num2str
is not needed.
2- You need to concatenate arrays, it doesn't happen automatically. therefore you need to ad the brackets []
.
Upvotes: 2