Merge the output from regionprops 'BoundingBox' into the format required for groundTruth.

5 views (last 30 days)
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

Accepted Answer

Matt J
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)
T = 5×2 table
Boxes Labels ____________ ____________ {4×4 double} {4×1 string} {3×4 double} {3×1 string} {3×4 double} {3×1 string} {6×4 double} {6×1 string} {5×4 double} {5×1 string}

More Answers (1)

Image Analyst
Image Analyst on 12 May 2022

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!