This is a source code in Matlab for Adaptive Median Filter. There is a main function whose name is AdaptiveFilter with two parameters. The first one is image variable (image matrix) and the second one is filter size.
In the following pictures the result of this function is shown and the filter size is set to 13.