bilateral filter Algorithm

Crucially, the weights depend not only on euclidean distance of pixels, but also on the radiometric differences (e.g., range differences, such as color intensity, depth distance, etc.).It replaces the intensity of each pixel with a weighted average of intensity values from nearby pixels.

bilateral filter source code, pseudocode and analysis