Inpainting, normal behavior or a bug?
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 artifacts 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) you can just pick it from the above images if you want to replicate the issue
Update:
@berak well I used the xphoto::inpaint()
that you suggested but though I do not get the black spot artifacts in the borders the quality of the image is not that good/smooth compared to the normal inpaint()
as you can see:
I do not know if I can modify any parameters in order to get a better result but as far as I looked there is not such an option. Therefore, I think I will stick to the normal inpaint()
hoping to get an answer about what is causing the artifacts in the borders.
did you try making a border around your image (say, a few pixels), so inpaint can kinda "wash out" there ?
(have not tried myself, just a blunt idea)
@berak nope I haven't tried that. But what pixel values should I use, for the make up border? Moreover, do you think that this behavior from
inpaint()
is a bug in the implementation code of the function? I was thinking to create an issue at github.Maybe inpaint() needs full context to work? Meaning, a black blob should have valid pixels all around ?
@Pedro Batista indeed this could be the case. On the other hand looking on the result by using xphoto module's version there isn't such a problem, of course it uses another method. To be honest I do not know, for that reason I am asking here. I think it would be a nice idea to open an issue at github and see what the devs would say, what do you think?
@theodore, just dare to make an issue. they won't bite ;)
@berak I will ;-). By the way you were right about making a border around the image. I will add the workaround in a while. I do not know though if it can be considered as a solution.
@berak Can you please help me here? link text