How do I update a struct array in a for loop?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mark Lepage
am 11 Sep. 2017
Bearbeitet: Stephen23
am 12 Sep. 2017
I am determining the equivalent diameter of circles in a series of images.
My code is as follows:
for k = 1:20
I = imread(k);
BW = im2bw(I);
stats = regionprops(BW,'EquivDiameter');
end
I would like the stats struct array to update the values so I get a summary of all the analyzed equivalent diameters, instead of just the last image which is what my code is giving me now. Any ideas?
Thanks,
Mark
0 Kommentare
Akzeptierte Antwort
Stephen23
am 11 Sep. 2017
Bearbeitet: Stephen23
am 11 Sep. 2017
stats(k) = ...
4 Kommentare
Stephen23
am 12 Sep. 2017
Bearbeitet: Stephen23
am 12 Sep. 2017
@Mark Lepage: if the data within C all have suitable sizes, you can certainly concatenate it into one structure afterwards:
cat(N,C{:}) % pick N for the dimension to concatenate along
Note that converting into one structure is a good idea, as it makes accessing the fields very convenient:
"To explain better what I am trying to do..."
It really doesn't matter to me if you are measuring bubbles or elephant ears: a cell array is a cell array, and a structure is a structure regardless. If you really wanted help you would give information about your data: what sizes it has, exactly the output you need, and you would upload some samples.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!