The kinect depth image has pixels with values equal to the calculated depth of object/surface in view. However, areas that absorb or scatter the kinect IR (like glossy surfaces or sharp edges) are filled with zero pixel value (indicating non-calculated depth). These regions with the missing information, represented by zero values, need to be filled prior to using the depth images. This filling process is done by replacing the zero value pixels with the statistical mode of the surrounding 25 pixels. Using a statistical mode returns sharper edges than using statistical mean values, since mode only inserts the maximum occurring value in the surrounding 25 pixels to the centre pixel.
Function Input: Kinect depth image (16-bit png)
Function Output: depth image with zero valued replaced , Number of zero pixels detected in the image.
The code is a matlab implementation of the algorithm used by Karl Sanford at Code Project (http://www.codeproject.com/Articles/317974/KinectDepthSmoothing)
I believe that the performance is very good.
Please add the sample usage to the script. Thanks otherwise !!
[filledImage,zeroPixels] = Kinect_DepthNormalization(depthImage);
Create scripts with code, output, and formatted text in a single executable document.