How to read multiple images from a folder, perform a function and store all the values one by one in an array form?

2 vues (au cours des 30 derniers jours)
Hey guys i am using the following code to read single image at a time, then performing few functions like the following
I=imread('1.bmp');
GLCM2=graycomatrix(I,'offset',[0 2],'symmetric',true);
stats2=GLCM_Features4(GLCM2,0);
t=struct2array(stats2);
When i run the above code i get the following result
In the same way i want to automate the process that can read the all images in the folder one by one and at the same time storing the values in the array. For example. In the following screenshot the first row in the array is the values calculated for Image(1.bmp). In the same way the code has to read image 2,image3,....image4,image99..and same time store the values in array as i pointed for image2.bmp and image3.bmp and so on..Please help me guys
  2 commentaires
Geoff Hayes
Geoff Hayes le 14 Juin 2014
Start with a for loop to iterate from 1 to 99 (or whatever the maximum number of images is). Assuming all your images are named as in your example, use sprintf to create the file name or something like
filename = [num2str(i) '.bmp'];
Do the work as above and then save the results to a matrix. Take the results of t and just concatenate it with the results from the previous iteration. Try it out and see what happens.
sai kiran thati
sai kiran thati le 14 Juin 2014
I am very new to Matlab Hayes. Could you write a sample program and explain it? Please

Connectez-vous pour commenter.

Réponse acceptée

Geoff Hayes
Geoff Hayes le 14 Juin 2014
Suppose you have 99 images and you want to process each one and save the results
n = 99; % number of images
statsMtx = []; % matrix for the stata data generated at each iteration
for i=1:n
filename = [num2str(i) '.bmp']; % create the filename give i
% now do what you have done already
% concatenate the new stats t into statsMtx
statsMtx =[statsMtx ; t];
end
Try the above and see what happens!
  3 commentaires

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 14 Juin 2014
This framework does exactly that: http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component. Just plug your code into the AnalyzeSingleImage() function, and it handles the collection of results from all images and storing into an Excel workbook.

Catégories

En savoir plus sur Images 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