I have a 2-d array of data that represents a surface. The surface was scanned with a laser, and the laser data has both upward and downward spikes. However, the surface also has legitimate topography (it is smooth, but with transitions). I would like to preserve the topography, but get rid of the spikes.
I have had success using a 7,7 median filter to remove the spikes. However, the median filter also removes a lot of the "valid" detail. So, I use the MAX function to compare the original data with the filtered data. That gives me a noise-free top surface, while preserving the data at the bottom. I also use the MIN function to get a noise-free bottom surface. So the max data now has downward spikes and the min data has upward spikes.
My challenge: Is there a way to combine these two surfaces, possibly including the original data, to get rid of both sets of spikes, while preserving the underlying detail? I think I almost want the opposite of a median of the three arrays, where if two of the three corresponding elements are the same, I want to keep the third one.