Drawing rectangles around binary image objects from region props

Technical Source
2 min readMar 16, 2023

--

Hi, from the binary image above, I’ve tried drawing boundaries around the object and successfully counted them. But I’m thinking of trying another method which is to use the regionprops to extract information of the location of the blobs. But I do not know how to draw a rectangle around them.

info = regionprops(img2,'Boundingbox')

By using this command, the command windows shows

4×1 struct array with fields:

BoundingBox

Which from what I guess is the total of bounding boxes it found from the image similar to the boundary way that I used. Can I use this information and draw a rectangle for the images and and display it in my source image?

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

info = regionprops(img2,'Boundingbox') ;
imshow(img2)
hold on
for k = 1 : length(info)
BB = info(k).BoundingBox;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','r','LineWidth',2) ;
end

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet