How to remove entries form a struct array?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
so I'm trying to remove certain entries from a struct array that I created using regionprops for extracting features from a segmentation.
[labeled, numObjects]= bwlabel(Iopenned, 4);
stats= regionprops(labeled, 'Eccentricity', 'Area', 'BoundingBox');
So 'Iopenned' is my segmented image which shows a binary image of circles. Due to the orignal image some areas of my segmentation (the circles) are connectet and therefore counted as one big circle (outer ring in the segmentation attachment). I would like to sort these kind of 'mistakes' out. Something like every identified circle with an area bigger than 300 will be removed from the struct array. So if e.g. the area of the first entry (like in the attachment) in the array is to big, I would like to remove the whole column so that after all I have an array with one less entry. Maybe it's possible to create a new struct array in which I could just copy the entries that pass my criteria?
Thanks in advance!
댓글 수: 0
채택된 답변
sloppydisk
2018년 6월 7일
Logical indexing should work, just note that you need brackets around s.area.
field1 = 'area'; value1 = num2cell(1:10) ;
field2 = 'eccentricity'; value2 = num2cell(41:50);
s = struct(field1,value1, field2, value2);
sReduced = s([s.area] > 5);
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!