Save data from for loop to a structure
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!