OpenCV的轮廓:如何消除小轮廓的二进制图像 [英] Contours opencv : How to eliminate small contours in a binary image

查看:721
本文介绍了OpenCV的轮廓:如何消除小轮廓的二进制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在对图像处理项目。我使用Opencv2.3.1用VC ++。
我已经写了code,使得输入图像进行滤波,以仅蓝色和转换为二进制图像。二进制图像有,我不想要一些小物件。我想消除这些小物件,所以我用的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..

这是我得到的二进制图像

这是我想要的结果/输出图像以获得:

推荐答案

好吧,我相信你的问题的可能的用<一个解决href=\"http://opencv.itseez.com/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.html\">the边界最近推出了OpenCV的演示箱

Ok, I believe your problem could be solved with the bounding box demo recently introduced by OpenCV.

您可能已经注意到了,你有兴趣的对象应该是在图片中的最大的矩形绘制中。幸运的是,这个code是不是很复杂,我敢肯定,你可以通过调查和用它进行试验弄清楚这一切了。

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的轮廓:如何消除小轮廓的二进制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆