Median smoothing of a vector, including points near its ends.
SMOOTHED = MEDSMOOTH( VECTOR, WINDOW_WIDTH )
VECTOR = The (1-d numeric) vector to be smoothed
WINDOW = Odd integer giving the full width of the window over which
the median is determined for each point. (If WINDOW is
specified as an even number, then the effect is the same as
Function returns the smoothed vector
Each point is replaced by the median of the nearest WINDOW of points.
The width of the window shrinks towards the ends of the vector, so that
only the first and last points are not filtered. These points are
replaced by forecasting from smoothed interior points.
Create a vector with isolated high points near its ends
IDL> a = randomn(seed,40) & a = 10 & a = 10
Now do median smoothing with a 7 point window
IDL> b = medsmooth(a,7)
Note that, unlike MEDIAN(), that MEDSMOOTH will remove the isolated
high points near the ends.
Written, H. Freudenreich, STX, 12/89
H.Freudenreich, 8/90: took care of end-points by shrinking window.
Speed up using vector median when possible W. Landsman February 2002