OpenCV how to find a list of connected components in a binary image(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如何在二进制图像中找到连接组件的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:OpenCV如何在二进制图像中找到连接组件的列表
基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 这个宏可以转换成函数吗? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
