How can i get a bounding box around the vehicles and not around all the objects in the image

6 views (last 30 days)
st = regionprops(bw_I, 'BoundingBox' );
for k= 1: length(st)
thisBB = st(k).BoundingBox;
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],...
'EdgeColor','g','LineWidth',2 )
end

Answers (1)

Tarunbir Gambhir
Tarunbir Gambhir on 3 Dec 2020
If you just want to get a bounding box around the vehicles in this particular image, you could set constraints on the size of the bounding box. The bounding boxes for the background objects in this image are either too big or too small, and hence I think you could set some threshold by trial and error. Keep in mind that these constraints might or might not work with other similar images for vehicle detection.
If you want to automate the processes of getting bounding boxes around vehicles in multiple images, an algorithm or logic is required for the identification and detection of vehicles and background objects. Usually this task is performed by a trained Deep Learning model. After the identification of the vehicles in the image, bounding boxes can be formed around them.
If this is what you are trying to achieve, I suggest you go through the MATLAB example on training a vehicle detector.

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!