r.thin.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <h2>DESCRIPTION</h2>
  2. <em>r.thin</em> scans the named <em>input</em> raster map layer and
  3. thins non-NULL cells that denote linear features into linear features
  4. having a single cell width. Raster lines often need to be thinned
  5. (skeletonizing raster features) to a single pixel width before they can
  6. be transformed to vector data.
  7. <p>
  8. <em>r.thin</em> will thin only the non-NULL (no data) raster cells
  9. of the named <em>input</em> raster map layer within the current
  10. geographic region settings. The cell width of the thinned
  11. <em>output</em> raster map layer will be equal to the cell
  12. resolution of the currently set geographic region. All of
  13. the thinned linear features will have the width of a single
  14. cell.
  15. <p>
  16. <em>r.thin</em> will create a new <em>output</em> raster
  17. data file containing the thinned linear features.
  18. <em>r.thin</em> assumes that linear features are encoded
  19. with positive values on a background of NULL's in the
  20. <em>input</em> raster data file, hence it creates a NULL/1
  21. output map.
  22. <h2>NOTES</h2>
  23. <em>r.thin</em> only creates raster map layers. In order to
  24. create a vector map, the user will need to run
  25. <em><a href="r.to.vect.html">r.to.vect</a></em>
  26. on the resultant raster map.
  27. <p>
  28. <em>r.thin</em> may create small spurs or "dangling lines"
  29. during the thinning process. These spurs may be removed
  30. (after creating a vector map layer) by
  31. <em><a href="v.clean.html">v.clean</a></em> (<em>rmdangle</em>
  32. tool).
  33. <p>
  34. This code implements the thinning algorithm described in
  35. "Analysis of Thinning Algorithms Using Mathematical
  36. Morphology" by Ben-Kwei Jang and Ronlad T. Chin in
  37. <em>Transactions on Pattern Analysis and Machine
  38. Intelligence</em>, vol. 12, No. 6, June 1990. The
  39. definition Jang and Chin give of the thinning process is
  40. "successive removal of outer layers of pixels from an
  41. object while retaining any pixels whose removal would alter
  42. the connectivity or shorten the legs of the sceleton."
  43. <p>
  44. The sceleton is finally thinned when the thinning process
  45. converges; i.e., "no further pixels can be removed without
  46. altering the connectivity or shortening the sceleton legs"
  47. (p. 541). The authors prove that the thinning process
  48. described always converges and produces one-pixel thick
  49. sceletons. The number of iterations depends on the
  50. original thickness of the object. Each iteration peels off
  51. the outside pixels from the object. Therefore, if the
  52. object is &lt;= n pixels thick, the algorithm should
  53. converge in &lt;= iterations.
  54. <h2>EXAMPLE</h2>
  55. To vectorize the raster map <em>streams_derived</em> in the North
  56. Carolina sample dataset that represents the stream network derived from
  57. the 10m resolution DEM by <em>r.watershed</em>, run:
  58. <div class="code"><pre>
  59. g.region raster=elevation -p
  60. # create flow accumulation map
  61. r.watershed elevation=elevation accumulation=accum_50K thresh=50000
  62. # extract streams from flow accumulation map
  63. r.mapcalc "streams_from_flow = if(abs(accum_50K) > 1000, 1, null())"
  64. # skeletonize map
  65. r.thin streams_from_flow out=streams_thin
  66. d.mon wx0
  67. d.rast streams_from_flow
  68. d.erase
  69. d.rast streams_thin
  70. </pre></div>
  71. <p>
  72. <center>
  73. <img src="r_thin_network.png" alt="Raster feature thinning (skeletonizing)"><br>
  74. Raster feature thinning (skeletonizing)
  75. </center>
  76. <p>
  77. The resulting map cabe optionally vectorized:
  78. <div class="code"><pre>
  79. r.to.vect streams_thin output=streams_thin type=line
  80. # visualize
  81. d.rast accum_50K
  82. d.vect streams_thin color=red width=2
  83. </pre></div>
  84. <p>
  85. <center>
  86. <img src="r_thin_vectorized.png" alt="Vectorized stream network after thinning extracted from flow accumulation map"><br>
  87. Vectorized stream network after thinning extracted from flow accumulation map
  88. </center>
  89. <!--
  90. # compare to official NC stream map
  91. d.erase
  92. d.vect streams_thin color=red width=2
  93. d.vect streams color=blue width=2
  94. -->
  95. <h2>SEE ALSO</h2>
  96. <em>
  97. <a href="g.region.html">g.region</a>,
  98. <a href="r.to.vect.html">r.to.vect</a>,
  99. <a href="v.clean.html">v.clean</a>,
  100. <a href="wxGUI.vdigit.html">wxGUI vector digitizer</a>,
  101. <a href="v.build.html">v.build</a>
  102. </em>
  103. <h2>AUTHOR</h2>
  104. Olga Waupotitsch, U.S.Army Construction Engineering Research Laboratory
  105. <p>The code for finding the bounding box as well as input/output code
  106. was written by Mike Baba (DBA Systems, 1990) and Jean Ezell (USACERL, 1988).
  107. <p><i>Last changed: $Date$</i>