필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to modify all the images in different folders under a folder

조회 수: 1 (최근 30일)
Jhilam Mukherjee
Jhilam Mukherjee 2016년 8월 31일
마감: MATLAB Answer Bot 2021년 8월 20일
I have 10 folders under a folder. Each folder contains nearly 200 images. I can aceess the folder using recurse_subfolders.m matlab file. While read or write operations are performed on these images. It generate error.
clc; % Clear the command window. workspace; % Make sure the workspace panel is showing. format long g; format compact;
% Define a starting folder. start_path = fullfile('E:\testing', '\testing'); if ~exist(start_path, 'dir') start_path = 'E:\testing\'; end % Ask user to confirm or change. uiwait(msgbox('Pick a starting folder on the next window that will come up.')); topLevelFolder = uigetdir(start_path); if topLevelFolder == 0 return; end % Get list of all subfolders. allSubFolders = genpath(topLevelFolder); % Parse into a cell array. remain = allSubFolders; listOfFolderNames = {}; while true [singleSubFolder, remain] = strtok(remain, ';'); if isempty(singleSubFolder) break; end listOfFolderNames = [listOfFolderNames singleSubFolder]; end numberOfFolders = length(listOfFolderNames)
% Process all image files in those folders. for k = 1 : numberOfFolders % Get this folder and print it out. thisFolder = listOfFolderNames{k}; filePattern = sprintf('%s/*.*', thisFolder); baseFileNames = dir(filePattern); tic numberOfImageFiles = length(baseFileNames); if numberOfImageFiles >= 1 for i=1:numberOfImageFiles filename = fullfile(thisFolder, baseFileNames(i).name); listing = dir; allDirNames = { listing.name }; dirLA = [ listing.isdir ]; dirLA(1:2) = 0; dirNames = allDirNames(dirLA); for idx = 1:length(dirNames) cd(dirNames{idx}) % assuming that all files in the directory to be run fileNames = ls; fileNames = cellstr(fileNames(3:end,:)); for id2 = 1:length(fileNames) %eval(fileNames{id2}(1:end-2)) srcFiles = dir('E:\testing\dirNames{idx}\*.jpg'); X=strcat('E:\testing\dirNames{id2}\',srcFiles(id2).name); % I{id2} = imread(fileNames); % figure,imshow(I{id2}); end cd .. end
end
end
end

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by