Take the median of the pixels immediately around the one you're interested in.
The same as for taking the mean(average) of the pixels.
Do you know the difference between mean and median?
Mean
For example, take the pixel on the bottom left with a value of 185
It's surrounded by 5 zeros
Take the mean
185 + 0 + 0 + 0 + 0 + 0 = 185
Divide by 6 gives 31 (to 2 sig figs)
The 185 pixel is replaced by one of value 31
And so on...