Save data from for loop to a structure

3 ビュー (過去 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
  1 件のコメント
Holmbrero
Holmbrero 2020 年 10 月 12 日
Thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by