Merge the output from regionprops 'BoundingBox' into the format required for groundTruth.
5 views (last 30 days)
Show older comments
The output from regionprops 'BoundingBox' from an image with multiple ROI's is, by default a 'struct' (structured array) with a row for each bounding box or a table. groundTruth (and boxLabelData) want the bounding box data as a comma seperated list. I can't work out how to combine the regionprops 'BoundingBox' data into the format required.

Output from regionprops for 1 image with 95 ROI's and 95 BoundingBox (95 bounding boxes in the 1 image)

This is an screen snip from a different data set and is just for context
gtruth table contents (for images 13 - 22) with bounding box data for 1 or 2 bounding boxes per image.
I feel like this should be really easy but can't work it out. I'm just learning Matlab and obviously a long way to go.
Cheers
0 Comments
Accepted Answer
Matt J
on 12 May 2022
Edited: Matt J
on 12 May 2022
Let's say you have bounding box data from calling regionprops on some number of image frames. Then, your loop to organize the box data and labels might look like below:
numFrames=5; %number of frames
for i=1:numFrames
Frame=rand(10)>0.6; %randomly generated image frame
S=regionprops( Frame,'BoundingBox');
bbox=vertcat(S.BoundingBox);
N=size(bbox,1);
Boxes{i,1}=bbox;
Labels{i,1}=string(randi(100,N,1)); %randomly generated box labels
end
T=table(Boxes,Labels)
More Answers (1)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!