MEDSMOOTH
Name
MEDSMOOTH
Purpose
Median smoothing of a vector, including points near its ends.
Calling Sequence
SMOOTHED = MEDSMOOTH( VECTOR, WINDOW_WIDTH )
Inputs
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
using WINDOW+1)
Output
Function returns the smoothed vector
Procedure
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.
Example
Create a vector with isolated high points near its ends
IDL> a = randomn(seed,40) & a[1] = 10 & a[38] = 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.
Revision History
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