From a73ed12dd7e01cb3c7d4cdae00680286a8b34d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9d=C3=A9ric=20Ribreux?= Date: Mon, 2 May 2016 14:59:36 +0200 Subject: [PATCH] Add i.segment algorithm --- .../algs/grass7/description/i.segment.txt | 16 +++++++++ .../plugins/processing/algs/grass7/ext/i.py | 2 +- .../processing/algs/grass7/ext/i_segment.py | 33 +++++++++++++++++++ .../processing/algs/grass7/ext/i_tasscap.py | 2 +- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 python/plugins/processing/algs/grass7/description/i.segment.txt create mode 100644 python/plugins/processing/algs/grass7/ext/i_segment.py diff --git a/python/plugins/processing/algs/grass7/description/i.segment.txt b/python/plugins/processing/algs/grass7/description/i.segment.txt new file mode 100644 index 00000000000..a66fb866421 --- /dev/null +++ b/python/plugins/processing/algs/grass7/description/i.segment.txt @@ -0,0 +1,16 @@ +i.segment +Identifies segments (objects) from imagery data. +Imagery (i.*) +ParameterMultipleInput|input|Input rasters|3|False +ParameterNumber|threshold|Difference threshold between 0 and 1|0.0|1.0|0.5|False +ParameterSelection|method|Segmentation method|region_growing|0 +ParameterSelection|similarity|Similarity calculation method|euclidean;manhattan|0 +ParameterNumber|minsize|Minimum number of cells in a segment|1|100000|1|True +ParameterNumber|memory|Amount of memory to use in MB|1|None|300|True +ParameterNumber|iterations|Maximum number of iterations|1|None|20|True +ParameterRaster|seeds|Name for input raster map with starting seeds|True +ParameterRaster|bounds|Name of input bounding/constraining raster map|True +*ParameterBoolean|-d|Use 8 neighbors (3x3 neighborhood) instead of the default 4 neighbors for each pixel|False +*ParameterBoolean|-w|Weighted input, do not perform the default scaling of input raster maps|False +OutputRaster|output|Segmented Raster +OutputRaster|goodness|Goodness Raster diff --git a/python/plugins/processing/algs/grass7/ext/i.py b/python/plugins/processing/algs/grass7/ext/i.py index 1f8e1808694..564096a3e0c 100644 --- a/python/plugins/processing/algs/grass7/ext/i.py +++ b/python/plugins/processing/algs/grass7/ext/i.py @@ -118,7 +118,7 @@ def regroupRasters(alg, field, groupField, subgroupField=None, sigsetField=None) command = 'i.group group={}{} input={}'.format( group.value, - ' subgroup={}'.format(subgroup.value) if subgroup else '', + ' subgroup={}'.format(subgroup.value) if subgroupField else '', ','.join([alg.exportedLayers[f] for f in rastersList]) ) alg.commands.append(command) diff --git a/python/plugins/processing/algs/grass7/ext/i_segment.py b/python/plugins/processing/algs/grass7/ext/i_segment.py new file mode 100644 index 00000000000..6fd217410e5 --- /dev/null +++ b/python/plugins/processing/algs/grass7/ext/i_segment.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +""" +*************************************************************************** + i_segment.py + ------------ + Date : March 2016 + Copyright : (C) 2016 by Médéric Ribreux + Email : medspx at medspx dot fr +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +*************************************************************************** +""" + +__author__ = 'Médéric Ribreux' +__date__ = 'March 2016' +__copyright__ = '(C) 2016, Médéric Ribreux' + +# This will get replaced with a git SHA1 when you do a git archive + +__revision__ = '$Format:%H$' + +from i import regroupRasters + + +def processCommand(alg): + # Regroup rasters + regroupRasters(alg, 'input', 'group') diff --git a/python/plugins/processing/algs/grass7/ext/i_tasscap.py b/python/plugins/processing/algs/grass7/ext/i_tasscap.py index 752dddd895d..e0f01a1575d 100644 --- a/python/plugins/processing/algs/grass7/ext/i_tasscap.py +++ b/python/plugins/processing/algs/grass7/ext/i_tasscap.py @@ -25,7 +25,7 @@ __copyright__ = '(C) 2016, Médéric Ribreux' __revision__ = '$Format:%H$' -from i import multipleOutputDir, verifyRasterNum, regroupRasters +from i import multipleOutputDir, verifyRasterNum from processing.core.parameters import getParameterFromString