how to save data of lots of images individually?
5 views (last 30 days)
Show older comments
Hallo everyone,
I would like to ask you a question about how to savel the datas individually after processing all the images.
I have already use the code here to run all the images from one folder automatically. now I could save all the datas of all the processing images and then make plots like, area distirbution, but this is for all the data together, now i would like to do is after i process the first image, then i get the first area distribution for first image, then second and so on.
I try to use the loop,
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
data(k)=Areas;
fprintf(1, 'Now reading %s\n', fullFileName);
but it does not work.
Thanks in advance
JL
0 Comments
Accepted Answer
Image Analyst
on 2 Apr 2023
You need to index the data variable with the loop variable, like
for k = 1 : numImages
data(k) = whatever;
end
Then you can display them however you like, for example plot data, or write data to a text file and open it up, or write data to an Excel workbook.
2 Comments
Image Analyst
on 12 Jul 2023
Regarding your edit today, you added (k) to the data assignment, which is fine if "Areas" is a scalar. But you don't say how you got it and because it's plural, I'm guessing that it's a vector of several values, not one single scalar. In that case it would throw and error unless data was a 2-D matrix with as many columns as Areas had. Attach your complete script if you want more help, but after you read this:
More Answers (1)
Walter Roberson
on 31 Mar 2023
Initialize a cell array the size of the number of images in the folder. As you go through and produce results, assign the result into the appropriate entry in the cell array.
Note: if the output for each image is exactly the same size, then it can be more space efficient to use a 3 or 4 dimensional array to store the results -- but whether it is more time efficient depends in part on what you are doing with the information.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!