Smoothing with a mask
Is there a way to apply a blur or median smoothing filter to an image, while supplying a mask of pixels that should be ignored?
I have a height map from a laser-scanner which I want to smooth. The map is not continuous; wherever the laser was not reflected, the map simply contains no height data.
If I arbitrarily set the height for missing values to zero (or any other value) and then blur the image, this will introduce a lot of error around these missing values, and around all edges and holes of objects.
So I need to supply a binary mask to the blur. Masked pixels should be ignored when calculating the new blur or median value of neighbor pixels.
How can I accomplish this?