Well as the title says I want to smooth a depth map which has blank spots (black spots where there is no depth information). Since this is a problem that other people have faced before I found this solution which works quite nice and it is based on inpainting functionality. However, after applying inpaint on the input image there are still have some black spots on the borders. My first thought was that this might have to do something with the used inpainting method (method by Alexandru Telea INPAINT_TELEA
), but changing it to the Navier-Stokes INPAINT_NS
based method didn't change the result. I do not really get what is happening and if it is a bug in the inpaint()
code or something that I should expect. Any ideas?
Input image:
Mask of no depth information pixels:
Output with the problem (notice the black spots on the left and top borders):
code i used:
Mat depth;
const unsigned char noDepth = 0; // change to 255, if values no depth uses max value or use the mask image
cv::inpaint(img, (img == noDepth), depth, 5.0, INPAINT_TELEA); // img is the 8-bit input image (depth map with blank spots)