Skip to content

Commit

Permalink
i.cutlines: use empty input support of i.edge (#461)
Browse files Browse the repository at this point in the history
- make use of new `i.edge -n` flag for empty input/output (#460) to avoid crashes when using tiling
- add Canny example with screenshot
  • Loading branch information
neteler committed Mar 1, 2021
1 parent 070abd5 commit 9c688a4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
39 changes: 32 additions & 7 deletions grass7/imagery/i.cutlines/i.cutlines.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,51 @@ <h2>NOTES</h2>
GridModule class in pygrass. For older GRASS GIS versions tiled edge
detection is thus only possible with <a href="i.edge.html">i.edge</a>.

<h2>EXAMPLE</h2>
<h2>EXAMPLES</h2>

Using default <a href="https://grass.osgeo.org/grass-stable/manuals/i.zc.html">i.zc</a> edge detection without tiling,
<h3>Zero-crossing edge detection </h3>

Using the default <a href="https://grass.osgeo.org/grass-stable/manuals/i.zc.html">i.zc</a>
edge detection without tiling,
default parameters and 10 horizontal and 10 vertical cutlines, creating
vector polygon output:

<div class="code"><pre>
g.region rast=ortho_2001_t792_1m -p
i.cutlines ortho_2001_t792_1m number_lines=10 output=ortho_tiles
# ortho photo subarea
g.region raster=ortho_2001_t792_1m n=221070 s=219730 -p
i.cutlines input=ortho_2001_t792_1m number_lines=10 output=ortho_tiles_zc
</pre></div>

<center>
<img src="i_cutlines_default.png" width="600" height="294" border="1"><br>
Irregular vector tiles created for the NC demo data set orthophoto
<a href="i_cutlines_default.png"><img src="i_cutlines_default.png" width="600" height="264" border="1"></a><br>
Irregular vector tiles created for the NC demo data set orthophoto (default setting)
</center>

<h3>Canny edge detection </h3>

Using the <a href="https://grass.osgeo.org/grass-stable/manuals/i.edge.html">i.edge</a>
Canny edge detection with tiling and (needed) tile overlap, increased memory,
two parallel processes and 10 horizontal and 10 vertical cutlines, creating
vector polygon output:

<div class="code"><pre>
# ortho photo subarea
g.region raster=ortho_2001_t792_1m n=221070 s=219730 -p
i.cutlines input=ortho_2001_t792_1m number_lines=10 edge_detection=canny \
tile_width=500 tile_height=500 overlap=10 memory=2000 processes=2 output=ortho_tiles_canny
</pre></div>

<center>
<a href="i_cutlines_canny.png"><img src="i_cutlines_canny.png" width="600" height="264" border="1"></a><br>
Irregular vector tiles created for the NC demo data set orthophoto (Canny edge detection)
</center>

<h2>REFERENCES</h2>

Soares, Anderson Reis, Thales Sehn K&ouml;rting, and Leila Maria Garcia Fonseca. 2016. "Improvements of the Divide and Segment Method for Parallel Image Segmentation." Revista Brasileira de Cartografia 68 (6), http://www.lsie.unb.br/rbc/index.php/rbc/article/view/1602.
Soares, Anderson Reis, Thales Sehn K&ouml;rting, and Leila Maria Garcia Fonseca. 2016.
"Improvements of the Divide and Segment Method for Parallel Image Segmentation."
Revista Brasileira de Cartografia 68 (6),
<a href="http://www.lsie.unb.br/rbc/index.php/rbc/article/view/1602">http://www.lsie.unb.br/rbc/index.php/rbc/article/view/1602</a>

<h2>SEE ALSO</h2>

Expand Down
4 changes: 3 additions & 1 deletion grass7/imagery/i.cutlines/i.cutlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def main():
temp_edge_map = "temp_icutlines_edgemap_%d" % os.getpid()
temp_maps.append([temp_edge_map, r])

gscript.message(_("Creating edge map"))
gscript.message(_("Creating edge map using <%s> edgedetection algorithm") % edge_detection_algorithm)
if edge_detection_algorithm == 'zc':
kwargs = {'input': inputraster,
'output': temp_edge_map,
Expand Down Expand Up @@ -284,10 +284,12 @@ def main():
overlap=overlap,
processes=processes,
split=False,
flags='n',
**kwargs)
grd.run()
else:
gscript.run_command('i.edge',
flags='n',
**kwargs)

else:
Expand Down
Binary file added grass7/imagery/i.cutlines/i_cutlines_canny.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified grass7/imagery/i.cutlines/i_cutlines_default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9c688a4

Please sign in to comment.