how to save data of lots of images individually?

1 Ansicht (letzte 30 Tage)
JM
JM am 31 Mär. 2023
Kommentiert: JM am 18 Jul. 2023
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

Akzeptierte Antwort

Image Analyst
Image Analyst am 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 Kommentare
Image Analyst
Image Analyst am 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:
JM
JM am 18 Jul. 2023
Hallo Image Analyst,
Thanks so much for your reply and advices.
I will reorganize my thoughts and express my question more clearly.
Thanks so much
best regards
JL

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 31 Mär. 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.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by