Contours opencv : How to eliminate small contours in a binary image(轮廓 opencv:如何消除二值图像中的小轮廓)
问题描述
我目前正在从事图像处理项目.我在 VC++ 中使用 Opencv2.3.1.我编写了这样的代码,将输入图像过滤为仅蓝色并转换为二进制图像.二进制图像有一些我不想要的小对象.我想消除那些小物体,所以我使用了 openCV 的 cvFindContours()
方法来检测二进制图像中的轮廓.但问题是我无法消除图像输出中的小物体.我使用了 cvContourArea()
函数,但没有正常工作..,侵蚀函数也没有正常工作.
I am currently working on image processing project. I am using Opencv2.3.1 with VC++.
I have written the code such that, the input image is filtered to only blue color and converted to a binary image. The binary image has some small objects which I don't want. I wanted to eliminate those small objects, so i used openCV's cvFindContours()
method to detect contours in Binary image. but the problem is I cant eliminate the small objects in the image output. I used cvContourArea()
function , but didn't work properly.. , erode function also didn't work properly.
所以请有人帮我解决这个问题..
So please someone help me with this problem..
我得到的二进制图像:
我想要获得的结果/输出图像:
The result/output image which I want to obtain :
推荐答案
好的,我相信您的问题可以用 OpenCV 最近引入的边界框演示.
Ok, I believe your problem could be solved with the bounding box demo recently introduced by OpenCV.
您可能已经注意到,您感兴趣的对象应该在图片中最大的矩形内.幸运的是,这段代码并不是很复杂,我相信你可以通过调查和试验来弄清楚.
As you have probably noticed, the object you are interested at should be inside the largest rectangle draw in the picture. Luckily, this code is not very complex and I'm sure you can figure it all out by investigating and experimenting with it.
这篇关于轮廓 opencv:如何消除二值图像中的小轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:轮廓 opencv:如何消除二值图像中的小轮廓
基础教程推荐
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01