How to open multiple folders for processing?
Ältere Kommentare anzeigen
I need to process images in the folder, and each folder contains many images.. how can I process images which are in multiple folder, which has to be open one at a time, process folder of images and continue to open another folder to process set of images available in it...?like this it should open folders and continue to process until all the folder specified are done...
Antworten (3)
Paul Shoemaker
am 26 Mär. 2018
0 Stimmen
Hema,
Since you don't provide more concrete details about your specific circumstances (code, examples, purpose, etc), I will give a fairly broad answer that hopefully points you in the right direction.
Feel free to respond back with more details if the below ideas miss the mark.
Consider using the Matlab "dir" function to scan for files, which you can have run recursively in newer versions of Matlab. Another newer feature you could use is the "datastore" approach. Type help for either dir or datastore and you should get some good info to help with what you need.
Paul Shoemaker
4 Kommentare
hp
am 27 Mär. 2018
Paul Shoemaker
am 27 Mär. 2018
Ok Hema,
Check out the help for dir. I think it will do what you want, but again you have to have a fairly recent version of Matlab.
Use something like this
myFiles = dir(fullfile(Parent_Directory,'**/*.*'));
This will get all files in sub-folders, or modify "*.*" to be "*.png" or whatever file format you have.
Then you can do something like the below to cycle through all the returned files and process them.
for idx = 1:numel(myFiles)
currentFile = fullfile(myFiles(idx).folder,myFiles(idx).name);
% Do some processing below
end
Hope this helps solve your problem.
Paul Shoemaker
hp
am 31 Mär. 2018
hp
am 3 Apr. 2018
Image Analyst
am 27 Mär. 2018
0 Stimmen
See my attached demo to go into folders and subfolders getting filenames.
Navyasree K.S.
am 12 Dez. 2020
0 Stimmen
i need to read the images,they are in differents folders in a same file.the imaages are .jpg.please help me
1 Kommentar
Image Analyst
am 12 Dez. 2020
You can use imageDatastore(), or use dir('**/*.jpg');
See the FAQ for code samples.
Don't use JPG images for image analysis if you can possibly avoid it. They have bad compression artifacts. Use PNG.
Kategorien
Mehr zu Image Sequences and Batch Processing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!