cvDilate/cvErode:如何避免分离对象之间的连接?
我想在 OpenCv 中分离对象,如下图所示: 但如果我使用 cvDilate 或 cvErode,对象会一起生长......如何使用 OpenCv 做到这一点?
I would like to separate objects in OpenCv like the following image it shows:
But if I am using cvDilate or cvErode the objects grow together... how to do that with OpenCv?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,OpenCV 没有“XOR 扩张”(尽管如果有的话那就太好了)。
为了获得类似的结果,您可以尝试腐蚀(如“d”中),并使用腐蚀的中心作为 Voronoi 分割的种子,然后您可以将其与原始图像进行 AND 运算。
As far as I know OpenCV does not have "dilation with XOR" (although that would be very nice to have).
To get similar results you might try eroding (as in 'd'), and using the eroded centers as seeds for a Voronoi segmentation which you could then AND with the original image.
腐蚀和膨胀后尝试对图像进行阈值处理以消除弱元素。只应保留强区域,从而改善对象分离。顺便说一下,您能否更清楚地了解 cvDilate 或 cvErode 的问题。
after erosion and dilate try thresholding the image to eliminate weak elements. Only strong regions should remain and thus improve the object separation. By the way could you be a little more clear about your problem with cvDilate or cvErode.
看起来您需要编写自己的扩张函数,然后自己添加异或功能。
根据 opencv 文档,这是 cvdilate 使用的规则:
dst=dilate(src,element): dst(x,y)=max((x',y') in element))src(x+x',y +y')
这是起点的伪代码(这不包括异或代码):
It looks like you will need to write your own dilate function and then add xor functionality yourself.
Per the opencv documentation, here is the rule that cvdilate uses:
dst=dilate(src,element): dst(x,y)=max((x',y') in element))src(x+x',y+y')
Here is pseudocode for a starting point (this does not include xor code):