필터 지우기
필터 지우기

how to save data of lots of images individually?

조회 수: 4 (최근 30일)
Jialin Men
Jialin Men 2023년 3월 31일
댓글: Jialin Men 2023년 7월 18일
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

채택된 답변

Image Analyst
Image Analyst 2023년 4월 2일
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
Image Analyst
Image Analyst 2023년 7월 12일
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:
Jialin Men
Jialin Men 2023년 7월 18일
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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2023년 3월 31일
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.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by