Save data from for loop to a structure

1 Ansicht (letzte 30 Tage)
Holmbrero
Holmbrero am 12 Okt. 2020
Kommentiert: Holmbrero am 12 Okt. 2020
Hi!
I have the following code:
Size1 = size(ca, 1);
Size2 = size(ca, 2);
for r = 1 : Size1
for c = 1 : Size2
OpenBinImage=bwareaopen(ca{r,c}, 20);
OpenBinImageNoHoles = imfill(OpenBinImage,'holes');
[BW_out,properties] = Imageanalysisfilterregions(OpenBinImageNoHoles)
end
end
Where ca is a cell with arbitrary number of logical entrys that is binary information from an image that is split up into regions earlier in the code.
If the code is correct, it should access each cell and perform the operations on them one by one.
properties is a structure with three fields (Area, Orientation, Perimiter).
For each iteration of the loop, i would like to save the data from the structure so that i get the following:
Region 1 - Area Orientation Perimiter
Region 2 - Area Orientation Perimiter
and so on for each of the regions of the original image.
If it is possible i would like to store it in a cell.
Any suggestions?
Regards,
Anders Holmberg

Akzeptierte Antwort

KSSV
KSSV am 12 Okt. 2020
Size1 = size(ca, 1);
Size2 = size(ca, 2);
BW = cell(Size1,Size2) ;
P = cell(Size1,Size2) ;
for r = 1 : Size1
for c = 1 : Size2
OpenBinImage=bwareaopen(ca{r,c}, 20);
OpenBinImageNoHoles = imfill(OpenBinImage,'holes');
[BW_out,properties] = Imageanalysisfilterregions(OpenBinImageNoHoles) ;
BW{r.c} = BW_out ;
P{r,c}= properties ;
end
end

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by