[GRASS-SVN] r53567 - grass-addons/grass7/imagery/i.segment
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 26 09:15:44 PDT 2012
Author: momsen
Date: 2012-10-26 09:15:43 -0700 (Fri, 26 Oct 2012)
New Revision: 53567
Modified:
grass-addons/grass7/imagery/i.segment/create_isegs.c
grass-addons/grass7/imagery/i.segment/iseg.h
grass-addons/grass7/imagery/i.segment/parse_args.c
Log:
added -f flag for final forced merge only processing mode.
Modified: grass-addons/grass7/imagery/i.segment/create_isegs.c
===================================================================
--- grass-addons/grass7/imagery/i.segment/create_isegs.c 2012-10-26 14:59:43 UTC (rev 53566)
+++ grass-addons/grass7/imagery/i.segment/create_isegs.c 2012-10-26 16:15:43 UTC (rev 53567)
@@ -221,6 +221,9 @@
* if this is implemented, move this assignment inside the do loop and make it a function of t. */
threshold = functions->threshold;
+ /* user has option to skip the normal growing steps and skip to the final merge. */
+ if(!functions->final_merge_only){
+
/* do while loop until no merges are made, or until t reaches maximum number of iterations */
do {
@@ -503,7 +506,8 @@
t++;
}
while (t <= functions->end_t && endflag == FALSE); /*end t loop, either reached max iterations or didn't merge any segments */
-
+ } /* end if from the final_merge_only flag */
+
if (t == 2 && files->bounds_map == NULL)
G_warning(_("No segments were created. Verify threshold and region settings."));
/* future enhancement, remove the "&& bounds_map == NULL" if we check for unique bounds values. */
@@ -530,7 +534,10 @@
/* ****************************************************************************************** */
- if (functions->min_segment_size > 1 && t > 2) { /* NOTE: added t > 2, it doesn't make sense to force merges if no merges were made on the original pass. Something should be adjusted first */
+ if ((functions->min_segment_size > 1 && t > 2) || functions->final_merge_only) {
+ /* NOTE: added t > 2, it doesn't make sense to force merges
+ * if no merges were made on the original pass.
+ * Something should be adjusted first */
if (files->bounds_map == NULL) {
G_message
Modified: grass-addons/grass7/imagery/i.segment/iseg.h
===================================================================
--- grass-addons/grass7/imagery/i.segment/iseg.h 2012-10-26 14:59:43 UTC (rev 53566)
+++ grass-addons/grass7/imagery/i.segment/iseg.h 2012-10-26 16:15:43 UTC (rev 53567)
@@ -93,6 +93,7 @@
int path; /* flag if we are using Rk as next Ri for non-mutually best neighbor. */
int limited; /* flag if we are limiting merges to one per pass */
int estimate_threshold; /* flag if we just want to estimate a suggested threshold value and exit. */
+ int final_merge_only; /* flag if we want to just run the final merge portion of the algorithm. */
/* todo: is there a fast way (and valid from an algorithm
standpoint) to merge all neighbors that are within some small %
Modified: grass-addons/grass7/imagery/i.segment/parse_args.c
===================================================================
--- grass-addons/grass7/imagery/i.segment/parse_args.c 2012-10-26 14:59:43 UTC (rev 53566)
+++ grass-addons/grass7/imagery/i.segment/parse_args.c 2012-10-26 16:15:43 UTC (rev 53567)
@@ -12,7 +12,7 @@
{
struct Option *group, *seeds, *bounds, *output, *method, *similarity, *threshold, *min_segment_size, *endt; /* Establish an Option pointer for each option */
struct Option *radio_weight, *smooth_weight;
- struct Flag *estimate_threshold, *diagonal, *weighted, *limited; /* Establish a Flag pointer for each option */
+ struct Flag *estimate_threshold, *diagonal, *weighted, *limited, *final; /* Establish a Flag pointer for each option */
struct Option *outband; /* optional saving of segment data, until a seperate module is written */
#ifdef VCLOSE
@@ -107,6 +107,11 @@
weighted->description =
_("Weighted input, don't perform the default scaling of input maps.");
+ final = G_define_flag();
+ final->key = 'f';
+ final->description =
+ _("Final forced merge only (skip the growing portion of the algorithm.");
+
/* Raster for initial segment seeds */
/* future enhancement: allow vector points/centroids for seed input. */
seeds = G_define_standard_option(G_OPT_R_INPUT);
@@ -221,6 +226,8 @@
* user has weighted values so scaling should be skipped. */
files->weighted = weighted->answer;
+ functions->final_merge_only = final->answer;
+
/* check if optional seeds map was given, if not, use all pixels as starting seeds. */
if (seeds->answer == NULL) {
files->seeds_map = NULL;
More information about the grass-commit
mailing list