Do a median smoothing for all pixels that differ from the median by
more then the threshold
Size gives the size of the box in which the median is computed
This must be an odd integer >= 3
Threshold is the change beyond which the pixel will be smoothed
Assumed to be 0 if omitted which means that all pixels are smoothed.