在 OpenCV 中使用轮廓?
我有多种轮廓,我需要从中绘制蒙版。为此,我需要在绘制轮廓时使用 CV_FILLED。但是,我的轮廓不是闭合的 - 因为它们不是完整的多边形,所以 CV_FILLED 不起作用。有人对如何“闭合”我的轮廓有任何建议吗?
PS:为了澄清起见,关闭是指所有段都没有连接。与多边形不同,多边形的形状是封闭的,而我的多边形是开放的。
I have a variety of contours, from which I need to draw masks. To do so, I need to use CV_FILLED when drawing the contours. However, my contours aren't closed - as in they aren't complete polygons, so the CV_FILLED thing won't work. Does anyone have any suggestions on how I can "close" my contours?
PS: For clarification, by closing I mean all segments aren't joined. Unlike a polygon, where the shape is closed off, mine is open.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了尝试 convexHull 之外,您还可以看看尝试形态运算符 腐蚀 和 扩张。您可以使用
iterations
参数多次应用侵蚀或膨胀运算符。另外,您可以发布包含您要分割的对象的图像吗?
In addition to trying convexHull, you can also look at trying the morphology operators erode and dilate. You can apply the erosion or dilation operators multiple times by using the
iterations
parameter.Also, could you post the image with the objects you are trying to segment?