我目前正在从事图像处理项目.我在 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:如何消除二值图像中的小轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!