Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Image Analyst
Image Analyst el 24 de Nov. de 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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by