Find bounding rectangle of objects in monochrome bitmaps

£可爱£侵袭症+ 提交于 2019-12-06 21:47:27

What you're looking for is called "Blob" detection, which detects groups of objects that stand out from their surrounding area. Depending on the complexity you need you can also track area, convexity, perimeter, bounding-box, etc. Blobs are used in lots of machine vision and inspection applications.

There are plenty of established algorithms on Wiki and the like.

There are also image processing libraries that you can look into, one that comes to mind is called AForge -- it's an open source library written in C#: aforge.net

Or else just search for "Blob detection" and you'll find tons of info on what you need.

Good luck!

If you have access to MATLAB you could take a look at the regionprops function source. It does a lot of things, including finding bounding boxes.

Basically you need to label all the pixels according to what connected component they belong to, and then you can take the minimum and maximum X and Y coordinates for each one.

What I would do is to look at any labeling algorithm. One which is easy to implement is the "Run-Track" algorithm. Then when your labeling is done you could find the (top, left, right, bottom) extreme pixels of each labeled object. It might not be the fastest way (since you will be scannning the image multiple times), but it will be easy to implement.

Here are lecture slides that (shortly) describe the RT-algorithm (along with one other): http://www.cvl.isy.liu.se/Education/UnderGraduate/TSBB08/DBgrk7.pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!