Clear Filters
Clear Filters

How to save datas of different images individually?

1 view (last 30 days)
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 image i get area data of second image and make a distribution about it. and so on.
I try to use the loop,
% Specify the folder where the files live.
myFolder = '';
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.bmp'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
data(k)=allAreas;
fprintf(1, 'Now reading %s\n', fullFileName);
but it does not work.
Thanks in advance
JL

Answers (1)

Rahul
Rahul on 12 Jul 2023
Hi Jialin,
There are a couple of things you can check before running the code given by you.
In the line,
filePattern = fullfile(myFolder, '*.bmp'); % Change to whatever pattern you need.
please check that the files that you have in your folder are of appropriate extension.
Secondly, in the loop , in this line
fullFileName = fullfile(theFiles(k).folder, baseFileName);
you can maybe change the first argument of fullfile to myFolder just to make sure that is not an issue.
Lastly I assume this line,
data(k)=allAreas;
takes data from the individual files, please make sure this would be correct.
Apart from this the code seems fine to access files sequentially.
Thanks.

Community Treasure Hunt

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

Start Hunting!