查找单色位图中对象的边界矩形
给定单色位图:
000000000000000000000000000000000000000 001000100000000000000000000000000000000 000101000000000000000000000000000000000 000010000000001000000000000000000000000 000101000000010100000000000000000000000 001000100000100010000000000000000000000 000000000000010100000000000000000000000 000000000000001000000000000000000000000 000000000000000000000000000000000000000 000000000000001111110000000000000000000 000000000000001000010000000000000000000 000000000000001000010000000000000000000 000000000000001111110000000000000000000 000000000000000000000000000000000000000 000000000000000000000000000000000000000 000000000000000000000000000000000000000
我希望能够找到位图上每个对象的边界矩形。
有没有我可以使用的既定算法?
Given a monochrome bitmap:
000000000000000000000000000000000000000 001000100000000000000000000000000000000 000101000000000000000000000000000000000 000010000000001000000000000000000000000 000101000000010100000000000000000000000 001000100000100010000000000000000000000 000000000000010100000000000000000000000 000000000000001000000000000000000000000 000000000000000000000000000000000000000 000000000000001111110000000000000000000 000000000000001000010000000000000000000 000000000000001000010000000000000000000 000000000000001111110000000000000000000 000000000000000000000000000000000000000 000000000000000000000000000000000000000 000000000000000000000000000000000000000
I want to be able to find the bounding rectangle of each object on the bitmap.
Are there any established algorithms that I can use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在寻找的称为“Blob”检测,它检测从周围区域中脱颖而出的对象组。 根据您需要的复杂性,您还可以跟踪面积、凸度、周长、边界框等。斑点用于许多机器视觉和检查应用程序。
Wiki 等上有很多已建立的算法。
您还可以查看一些图像处理库,我想到的一个是 AForge ——它是一个用 C# 编写的开源库: aforge.net
或者只需搜索“Blob 检测”,您就会找到大量有关您需要的信息。
祝你好运!
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!
如果您可以访问 MATLAB,则可以查看
regionprops
函数源代码。 它可以做很多事情,包括寻找边界框。基本上,您需要根据所有像素所属的连通分量来标记它们,然后您可以获取每个像素的最小和最大 X 和 Y 坐标。
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.
我要做的就是查看任何标记算法。 一种易于实现的算法是“Run-Track”算法。
然后,当标记完成后,您可以找到每个标记对象的(上、左、右、下)极端像素。
这可能不是最快的方法(因为您将多次扫描图像),但它很容易实现。
以下是(简短地)描述 RT 算法(以及其他算法)的讲座幻灯片:http://www.cvl.isy.liu.se/Education/UnderGraduate/TSBB08/DBgrk7.pdf
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