Effacer les filtres
Effacer les filtres

how a function can be applied to loop of inputs(images) from folder

2 vues (au cours des 30 derniers jours)
parul mittal
parul mittal le 24 Nov 2016
Commenté : parul mittal le 25 Nov 2016
I have function i.e function t = txture( f, scale ) containing some features. I need to call it for loop of images that I m reading using dir command from folder and need to store the output of function in one variable for all the images. kindly help me.
thnx

Réponse acceptée

Image Analyst
Image Analyst le 24 Nov 2016
Put your function inside your loop.
% Specify the folder where the files live.
myFolder = 'C:\Users\yourUserName\Documents\My Pictures';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.jpg'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
t(k) = txture( f, scale );
end

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by