Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
accessing multiple images from multiple folders
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i have multiple folders .Each folder contain multiple images. i want to perform some transformation on those images and once its finish , i want to save those transformed images in different folders inside the parent folder where my original images are. For example: right now i have something like this:data ->data-1 ->image1.jpeg, image2.jpeg. once i finish the operation on each images , i want to do save like data ->transformdata-1 ->transformimage1.jpeg, transformimage2.jpeg. Similarly for data-2, data-3 ..till data-57 folders.
Till now i am trying this code but it's not a complete answer. i guess it doesn't have way individually identify each folder and start creating new folder corresponding to the original folder :
function fileList = getAllFiles(dirName)
dirData = dir(dirName); %# Get the data for the current directory
dirIndex = [dirData.isdir]; %# Find the index for directories
fileList = {dirData(~dirIndex).name}'; %'# Get a list of the files
if ~isempty(fileList)
fileList = cellfun(@(x) fullfile(dirName,x),... %# Prepend path to files
fileList,'UniformOutput',false);
end
subDirs = {dirData(dirIndex).name}; %# Get a list of the subdirectories
validIndex = ~ismember(subDirs,{'.','..'}); %# Find index of subdirectories
%# that are not '.' or '..'
for iDir = find(validIndex) %# Loop over valid subdirectories
nextDir = fullfile(dirName,subDirs{iDir}); %# Get the subdirectory path
fileList = [fileList; getAllFiles(nextDir)]; %# Recursively call getAllFiles
for k = 1:length(fileList)
x = fileList{k};
imread(x);
imshow(x);
end
end
end
0 Commenti
Risposte (0)
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!