我有一个图像,我正在侵蚀和膨胀,就像这样:
kernel = np.ones((5,5),np.float32)/1
eroded_img = cv2.erode(self.inpainted_adjusted_image, kernel, iterations=10)
dilated_img = cv2.dilate(eroded_img, kernel, iterations=10)
以下是腐蚀和膨胀的结果:
然后我就开始这样做了:
^{pr2}$但是阈值给了我一个不需要的扩展,我已经在下面的图像中标记了(红线上方的区域是不需要的区域):
我如何摆脱这个不受欢迎的区域?有没有更好的方法来做我正在做的事?在
使用不同类型的阈值(adaptivethreshold,它考虑了局部的亮度)已经可以解决您的问题:自适应阈值结果就是您要寻找的。在
[编辑:我冒昧地在Hough circles上添加了一些代码。我承认,为了得到一个好看的结果,我使用了这张图像的参数,尽管我不知道您需要什么类型的精度来解决此类问题]
如果这还不够,请告诉我们。在
从二值图像可以很容易地用Hough变换拟合一个圆。一旦你有了圆的外边界,我建议你把边界流血,然后把边界外的部分剪出来。在
另一种方法是调整阈值。看来你可以逃脱惩罚。你可能需要一些形态学操作来获得一个干净的边缘。使用磁盘内核将有助于在很大程度上保留形状。在
由于您的问题已经被回滚到其原始版本,我已经附加了一个解决方案,使用洪水填充,这对您的图像起作用。在
相关问题 更多 >
编程相关推荐