Question
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?
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 28, 2026
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
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related image processing Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →