OpenCV如何在二进制图像中找到连接组件的列表

OpenCV how to find a list of connected components in a binary image(OpenCV如何在二进制图像中找到连接组件的列表)
本文介绍了OpenCV如何在二进制图像中找到连接组件的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 OpenCV 用于 C++ 应用程序.我有一个包含一些对象的 8 位二进制图像.所有对象的颜色均为 255,而背景中的所有内容的颜色均为 0.每个对象内部都没有空白(黑色)像素.换句话说,每个对象都是全白的.这些对象没有相互连接.以下是我想从中提取的内容:

I am using OpenCV for a C++ application. I have a 8 bit binary image that has some objects. The objects are all colored 255, whereas everything in the background is colored 0. Each object has no vacant (black) pixels inside it. In other words, each object is fully white. The objects are NOT connected to each other. Here's what I want to extract from this:

我想提取某种对象列表,从中我可以了解每个对象在该列表中的位置.这可能是使用 cvConnectedComponents() 或其他任何东西.我需要一些指示每个对象在图像中的位置.这可能是每个对象的边界矩形或基于某些计算的中值或中心的形式,或者任何可以让我测量图像中对象位置的东西.任何指向要研究的 OpenCV 函数的指针?

I want to extract some kind of list of objects, from which I have some notion of the location of each object in that list. This could be using cvConnectedComponents() or anything else. I need some indication of where each object is located in the image. This could be in the form of bounding rectangle for each object or median or center based on some computation or anything that gives me a measure of the objects location in the image. Any pointers to what OpenCV functions to look into?

推荐答案

需要对cv::flood填充cv::findCountours返回的轮廓.findContours 参见 本示例,以及 这个 用于 floodFill

You need to cv::floodFill the contours returned by cv::findCountours. See this example for findContours, and this one for floodFill

这篇关于OpenCV如何在二进制图像中找到连接组件的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)