Save data from for loop to a structure

1 visualización (últimos 30 días)
Holmbrero
Holmbrero el 12 de Oct. de 2020
Comentada: Holmbrero el 12 de Oct. de 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

Respuesta aceptada

KSSV
KSSV el 12 de Oct. de 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

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by