top banner
Gri Commands
1: Introduction
2: Simple example
3: Fancy example
4: Running Gri
5: Programming Gri
6: General Issues
7: X-Y Plots
8: Contour Plots
9: Image Plots
10: Examples
11: Handling Data
12: Gri Commands
13: Gri Extras
14: Evolution of Gri
15: Installing Gri
16: Gri Bugs
17: System Tools
18: Acknowledgments
19: License
20: Newsgroup

21: Concept Index
navigate navigate navigate navigate navigate navigate

12.12: The `filter' Command

  • `filter column x|y|z|u|v|r|theta recursively a[0] a[1] ... b[0] b[1] ...' Filter indicated column, using a two-pass recursive filter. The first pass runs from the start to the end, while the second pass runs from the end to the start; in this way, the phase shift inherent in this type of filter is removed entirely. The coefficients are used in the following formula (demonstrated on the `x' column):
    x_new[i] = b[0] * x[i] \
      + b[1] * x[i-1] \
      + b[2] * x[i-2] \
      + ... \
      - a[1] * x_new[i-1] \
      - a[2] * x_new[i-2] \
      - ...
    
    Thus, for example, setting `a[i]' = 0 results in a simple backwards-looking moving-average filter applied in two passes. The real power of this type of filter, however, comes when non-zero `a[i]' coefficients are given, thus adding recursion (i.e., `x_new[i]' depends on `x_new[i-...]'). See any standard reference on digital filters for an explanation. You might find that the Matlab command `butter' an easy way to design filter coefficients. Here are some examples:
    # Filter x column with simple 2-point moving
    # average.  (This slurs into a 3-point moving
    # average, in effect, since the filter is run
    # forwards and then backwards.)
    filter column x recursively 0 0 0.5 0.5
    
    # Use filter designed with the Matlab 
    # command butter(2,0.1), which creates a 
    # 2nd order lowpass butterworth filter
    # with a cutoff frequency of 0.1 
    # (in units which have a frequency 
    # of 1 corresponding to one-half the
    # sampling rate).
    filter column x recursively \
        1     -1.561  0.6414 \
        0.0201 0.0402 0.0201
    
  • `filter grid rows|columns recursively a[0] a[1] ... b[0] b[1] ...' Apply recursive filter (see `filter column ... recursively' for meaning of this filter operation) to the individual rows or columns of the grid data. For example, `filter grid columns recursively 0 0 0.5 0.5' applies a 2-point moving average filter across the columns, smoothing the grid in the x-direction.
  • `filter image highpass' Remove low-wavenumber components from image (ie, sharpen edges). Do this by subtracting a Laplacian smoothed version of the image.
  • `filter image lowpass' Remove high-wavenumber components from image (ie, smooth shapes). Do this by Laplacian smoothing.
See also see Smooth.
bottom banner