Filling from colour distance field
Use the colour distance field to correct depth edges and fill holes. For edge correction the logic is: a discontinuity where the distance field increases as you cross from good to bad depth means the depth has gone over the edge, whereas if the field is decreasing from good to missing depth it means the edge has not been reached yet. This applies if the magnitude of the field is below a low threshold. Above a higher threshold, it means there is a hole to be filled instead if the gradient increases from good to missing depth.
Edited by Nicolas Pope