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:如何消除二值图像中的小轮廓


基础教程推荐
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01