I'm doing a project with depth image. But I have problems with noise and failed pixel reading with my depth camera. There are some spots and contours (especially edges) that have zero value. How to just ignore this zero value and blend it with surrounding values?
I have tried dilation
and erosion
(morph image processing), but I still can't get the right combination. It indeed removed some of the noise, but I just need to get rid of zeros at all points
图片示例:
零值是最深的蓝色(我正在使用颜色图)
为了说明我想做的事,请参考这张糟糕的油漆图:
I want to get rid the black spot (for example black value is 0 or certain value), and blend it with its surround.
Yes, I'm able to localized the spot using np.where
or the similar function, but I have no idea how to blend it. Maybe a filter to be applied? I need to do this in a stream, so I need a fairly fast process, maybe 10-20 fps will do. Thank you in advance!
更新:
除了修补以外,还有其他方法吗?我一直在寻找各种喷绘,但是我不需要像喷绘这样的复杂技术。我只需要将其与简单的直线,曲线或形状以及1D混合即可。我认为上漆太过分了。此外,我需要它们足够快以用于10-20 fps的视频流,甚至更好。
也许使用经过NaN调整的高斯滤波器既好又快速?当您将零点/黑点视为NaN时,此方法也适用于较大的黑色区域。
Image inpainting in both OpenCV and Skimage is too slow and it is a known issue. I don't think that you can speedup things without going deep into the algorithm.
If you are really interested in "traditional" (i.e. without deep learning) inpainting algorithms and ready to implement one, I'd strongly suggest to take a look at soupault/scikit-inpaint#4. That algorithm performs visually equal or superior to biharmonic method and, once properly turned into the code, can be really fast even for large images.
实际上,在性能上,双谐波修复的实现还远非最佳。当前版本非常直接,因为它是针对nD输入支持作为主要目标而编写的。
可能的实施改进包括但不限于:
作为一种中间解决方案,可以尝试为2D(+ color)实现更快的Cythonized版本(考虑到上面的其他要点),因为它有望成为最常见的用例。
If you are looking just for a "fast and good enough" inpainting method, take a look at the numerous deep-learning-based solutions for inpainting on GitHub.
这是在Python / OpenCV中执行此操作的一种方法。
使用中值过滤来填补漏洞。
输入:
阈值图像作为掩码:
倒罩:
中值过滤图像:
遮罩的图像:
屏蔽的中值滤波图像:
结果: