r.mfilter.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <h2>DESCRIPTION</h2>
  2. <em>r.mfilter.fp</em> filters the raster <em>input</em> to produce the
  3. raster <em>output</em> according to the matrix <em>filter</em> designed
  4. by the user (see <em>FILTERS</em> below).
  5. The filter is applied <em>repeat</em> times (default <em>value</em> is 1).
  6. The <em>output</em> raster map layer can be given a <em>TITLE</em> if desired.
  7. (This TITLE should be put in quotes if it contains more than one word.)
  8. With <b>-z</b> flag the filter is applied only to null values in
  9. the input raster map layer. The non-null category values are not changed.
  10. Note that if there is more than one filter step, this rule is applied to the
  11. intermediate raster map layer -- only null category values which result from
  12. the first filter will be changed. In most cases this will NOT be the
  13. desired result. Hence -z should be used only with single step filters.
  14. <p>
  15. The <b>filter</b> parameter defines the name of an existing, user-created
  16. UNIX ASCII file whose contents is a matrix defining the way in which the
  17. <em>input</em> file will be filtered. The format of this file is described
  18. below, under FILTERS.
  19. <p>
  20. The <b>repeat</b> parameter defines the number of times the <em>filter</em>
  21. is to be applied to the <em>input</em> data.
  22. <h2>FILTERS</h2>
  23. The <em>filter</em> file is a normal UNIX ASCII file designed by the user.
  24. It has the following format:
  25. <pre>
  26. TITLE TITLE
  27. MATRIX n
  28. .
  29. n lines of n values
  30. .
  31. DIVISOR d
  32. TYPE S/P
  33. </pre>
  34. <dl>
  35. <dt>TITLE
  36. <dd>A one-line TITLE for the filter.
  37. If a TITLE was not specified on the command line, it can be specified here.
  38. This TITLE would be used to construct a TITLE for the resulting raster map
  39. layer. It should be a one-line description of the filter.
  40. <dt>MATRIX
  41. <dd>The matrix (n x n) follows on the next n lines. <em>n</em> must be
  42. an odd integer greater than or equal to 3.
  43. The matrix itself consists of n rows of n values.
  44. The values must be separated from each other by at least 1 blank.
  45. <dt>DIVISOR
  46. <dd>The filter divisor is <em>d</em>. If not specified, the default is 1.
  47. If the divisor is zero (0), then the divisor is dependent on the
  48. category values in the neighborhood
  49. (see HOW THE FILTER WORKS below).
  50. <dt>TYPE
  51. <dd>The filter type. <em>S</em> means sequential, while <em>P</em> mean parallel.
  52. If not specified, the default is S.
  53. <p>
  54. Sequential filtering happens in place. As the filter is applied to the
  55. raster map layer, the category values that were changed in neighboring
  56. cells affect the resulting category value of the current
  57. cell being filtered.
  58. <p>Parallel filtering happens in such a way that the original raster
  59. map layer category values are used to produce the new category value.
  60. <p>More than one filter may be specified in the filter file.
  61. The additional filter(s) are described just like the first.
  62. For example, the following describes two filters:
  63. </dl>
  64. <h2>EXAMPLE FILTER FILE</h2>
  65. <pre>
  66. TITLE 3x3 average, non-null data only, followed by 5x5 average
  67. MATRIX 3
  68. 1 1 1
  69. 1 1 1
  70. 1 1 1
  71. DIVISOR 0
  72. TYPE P
  73. MATRIX 5
  74. 1 1 1 1 1
  75. 1 1 1 1 1
  76. 1 1 1 1 1
  77. 1 1 1 1 1
  78. 1 1 1 1 1
  79. DIVISOR 25
  80. TYPE P
  81. </pre>
  82. <h2>HOW THE FILTER WORKS</h2>
  83. The filter process produces a new category value for each cell
  84. in the input raster map layer by multiplying the category values of the
  85. cells in the n x n neighborhood around the center cell
  86. by the corresponding matrix value and adding them together.
  87. If a divisor is specified, the sum is divided by this divisor.
  88. (If a zero divisor was specified, then
  89. the divisor is computed for each cell as the sum of the MATRIX
  90. values where the corresponding input cell is non-null.)
  91. <p>
  92. If more than one filter step is specified, either because the
  93. repeat value was greater than one or because the filter file
  94. contained more than one matrix, these steps are performed
  95. sequentially. This means that first one filter is applied to
  96. the entire input raster map layer to produce an intermediate result;
  97. then the next filter is applied to the intermediate result to
  98. produce another intermediate result; and so on, until the
  99. final filter is applied. Then the output cell is written.
  100. <h2>NOTES</h2>
  101. If the resolution of the geographic region does not agree with the
  102. resolution of the raster map layer, unintended resampling of the original
  103. data may occur. The user should be sure that the geographic region
  104. is set properly.
  105. <h2>SEE ALSO</h2>
  106. <em><a href="g.region.html">g.region</a></em>,
  107. <em><a href="r.clump.html">r.clump</a></em>,
  108. <em><a href="r.neighbors.html">r.neighbors</a></em>
  109. <em><a href="r.mfilter.html">r.mfilter</a></em>
  110. <h2>AUTHOR</h2>
  111. Glynn Clements.
  112. Based upon r.mfilter, by Michael Shapiro,
  113. U.S.Army Construction Engineering Research Laboratory
  114. <p><i>Last changed: $Date$</i>