Save data from for loop to a structure

조회 수: 1 (최근 30일)
Holmbrero
Holmbrero 2020년 10월 12일
댓글: Holmbrero 2020년 10월 12일
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

채택된 답변

KSSV
KSSV 2020년 10월 12일
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

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by