The SMOOTH function returns a copy of Array smoothed with a boxcar average of the specified width. The result has the same type and dimensions as Array. The algorithm used by SMOOTH is:
where N is the number of elements in A.
Result = SMOOTH( Array, Width [, /EDGE_TRUNCATE] [, MISSING=value] [, /NAN] )
Returns the smoothed array, which has the same dimensions as the input array.
The array to be smoothed. Array can have any number of dimensions.
The width of the smoothing window. Width can either be a scalar or a vector with length equal to the number of dimensions of Array. If Width is a scalar then the same width is applied for each dimension that has length greater than 1 (dimensions of length 1 are skipped). If Width is a vector, then each element of Width is used to specify the smoothing width for each dimension of Array. Values for Width must be smaller than the corresponding Array dimension. If a Width value is even, then Width+1 will be used instead. The value of Width does not affect the running time of SMOOTH to a great extent.
| Note |
| Tip |
Set this keyword to apply the smoothing function to all points. If the neighborhood around a point includes a point outside the array, the nearest edge point is used to compute the smoothed result. If EDGE_TRUNCATE is not set, the end points are copied from the original array to the result with no smoothing.
For example, when smoothing an n-element vector with a three point wide smoothing window, the first point of the result R0 is equal to A0 if EDGE_TRUNCATE is not set, but is equal to (A0+A0+A1)/3 if the keyword is set. In the same manner, point Rn-1 is set to An-1 if EDGE_TRUNCATE is not set, or to (An-2+An-1+An-1)/3 if it is.
Points not within a distance of Width/2 from an edge are not affected by this keyword.
| Note |
The value to return for elements that contain no valid points within the kernel. The default is the IEEE floating-point value NaN. This keyword is only used if the NAN keyword is set.
Set this keyword to cause the routine to check for occurrences of the IEEE floating-point values NaN or Infinity in the input data. Elements with the value NaN or Infinity are treated as missing data. (See Special Floating-Point Values for more information on IEEE floating-point values.) Elements with the value NaN are treated as missing data, and are ignored when computing the smooth value for neighboring elements. In the Result, missing elements are replaced by the smoothed value of all other valid points within the smoothing window. If all points within the window are missing, then the result at that point is given by the MISSING keyword.
| Note |
Create and display a simple image by entering:
WINDOW, XSIZE=800, YSIZE=400 D = SIN(DIST(256)/3) TVSCL, D
Now display the same dataset smoothed with a width of 9 in each dimension by entering:
TVSCL, SMOOTH(D, 9), 256, 0
Now smooth only in the vertical direction with a width of 15:
TVSCL, SMOOTH(D, [1, 15]), 512, 0
Introduced: Original
DIGITAL_FILTER, LEEFILT, MEDIAN, TS_DIFF, TS_FCAST, TS_SMOOTH