[GRASS-SVN] r69061 - sandbox/metz/i.segment.ms
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 2 12:34:24 PDT 2016
Author: mmetz
Date: 2016-08-02 12:34:24 -0700 (Tue, 02 Aug 2016)
New Revision: 69061
Modified:
sandbox/metz/i.segment.ms/iseg.h
sandbox/metz/i.segment.ms/main.c
sandbox/metz/i.segment.ms/mean_shift.c
sandbox/metz/i.segment.ms/parse_args.c
sandbox/metz/i.segment.ms/write_output.c
Log:
sandbox: i.segment + mean shift: polishing UI
Modified: sandbox/metz/i.segment.ms/iseg.h
===================================================================
--- sandbox/metz/i.segment.ms/iseg.h 2016-08-02 13:50:46 UTC (rev 69060)
+++ sandbox/metz/i.segment.ms/iseg.h 2016-08-02 19:34:24 UTC (rev 69061)
@@ -67,9 +67,8 @@
/* output */
/* region growing */
char *out_name; /* name of output raster map with regions */
- char *out_band; /* indicator for segment heterogeneity / goodness of fit */
- /* mean_shift */
- char *ms_suf; /* suffix to be appended to input bands */
+ char *gof; /* indicator for segment heterogeneity / goodness of fit */
+ char *bsuf; /* suffix to be appended to input bands */
/* general segmentation */
int method; /* Segmentation method code */
Modified: sandbox/metz/i.segment.ms/main.c
===================================================================
--- sandbox/metz/i.segment.ms/main.c 2016-08-02 13:50:46 UTC (rev 69060)
+++ sandbox/metz/i.segment.ms/main.c 2016-08-02 19:34:24 UTC (rev 69061)
@@ -54,12 +54,12 @@
if (write_ids(&globals) != TRUE)
G_fatal_error(_("Error in writing IDs"));
- if (globals.method == ORM_RG && globals.out_band) {
+ if (globals.method == ORM_RG && globals.gof) {
if (write_gof_rg(&globals) != TRUE)
G_fatal_error(_("Error in writing goodness of fit"));
}
- if (globals.method == ORM_MS) {
+ if (globals.method == ORM_MS && globals.bsuf) {
if (write_bands_ms(&globals) != TRUE)
G_fatal_error(_("Error in writing new band values"));
}
Modified: sandbox/metz/i.segment.ms/mean_shift.c
===================================================================
--- sandbox/metz/i.segment.ms/mean_shift.c 2016-08-02 13:50:46 UTC (rev 69060)
+++ sandbox/metz/i.segment.ms/mean_shift.c 2016-08-02 19:34:24 UTC (rev 69061)
@@ -238,7 +238,7 @@
/* spectral bandwidth: reduce by 0.7 */
if (t > 1)
- hspec *= 0.7;
+ hspec *= 0.9;
hspec2 = hspec * hspec;
sigmaspec2 = hspec2 / 9.;
Modified: sandbox/metz/i.segment.ms/parse_args.c
===================================================================
--- sandbox/metz/i.segment.ms/parse_args.c 2016-08-02 13:50:46 UTC (rev 69060)
+++ sandbox/metz/i.segment.ms/parse_args.c 2016-08-02 19:34:24 UTC (rev 69061)
@@ -11,24 +11,23 @@
{
struct Option *group, *seeds, *bounds, *output,
*method, *similarity, *threshold, *min_segment_size,
- *hs, *hr, *ms_suf,
+ *hs, *hr, *bsuf,
#ifdef _OR_SHAPE_
*shape_weight, *smooth_weight,
#endif
*mem;
struct Flag *diagonal, *weighted, *ms_a, *ms_p;
- struct Option *outband, *endt;
+ struct Option *gof, *endt;
/* required parameters */
group = G_define_standard_option(G_OPT_I_GROUP);
output = G_define_standard_option(G_OPT_R_OUTPUT);
- ms_suf = G_define_standard_option(G_OPT_R_OUTPUT);
- ms_suf->key = "ms";
- ms_suf->required = NO;
- ms_suf->answer = "_ms";
- ms_suf->label = _("Suffix for output bands (mean shift)");
+ bsuf = G_define_standard_option(G_OPT_R_OUTPUT);
+ bsuf->key = "band_suffix";
+ bsuf->required = NO;
+ bsuf->label = _("Suffix for output bands with modified band values");
threshold = G_define_option();
threshold->key = "threshold";
@@ -40,10 +39,11 @@
/* optional parameters */
hs = G_define_option();
- hs->key = "hs";
+ hs->key = "radius";
hs->type = TYPE_DOUBLE;
hs->required = NO;
- hs->label = _("Spatial bandwidth in number of cells");
+ hs->answer = "1.5";
+ hs->label = _("Spatial radius in number of cells");
hs->description = _("Must be >= 1, only cells within spatial bandwidth are considered for mean shift");
hr = G_define_option();
@@ -136,10 +136,10 @@
bounds->description =
_("Must be integer values, each area will be segmented independent of the others");
- outband = G_define_standard_option(G_OPT_R_OUTPUT);
- outband->key = "goodness";
- outband->required = NO;
- outband->description =
+ gof = G_define_standard_option(G_OPT_R_OUTPUT);
+ gof->key = "goodness";
+ gof->required = NO;
+ gof->description =
_("Name for output goodness of fit estimate map");
diagonal = G_define_flag();
@@ -179,7 +179,7 @@
else
G_fatal_error("Invalid output raster name");
- globals->ms_suf = ms_suf->answer;
+ globals->bsuf = bsuf->answer;
globals->alpha = atof(threshold->answer);
if (globals->alpha <= 0 || globals->alpha >= 1)
@@ -317,11 +317,11 @@
}
/* debug help */
- if (outband->answer == NULL)
- globals->out_band = NULL;
+ if (gof->answer == NULL)
+ globals->gof = NULL;
else {
- if (G_legal_filename(outband->answer) == TRUE)
- globals->out_band = outband->answer;
+ if (G_legal_filename(gof->answer) == TRUE)
+ globals->gof = gof->answer;
else
G_fatal_error(_("Invalid output raster name for goodness of fit"));
}
Modified: sandbox/metz/i.segment.ms/write_output.c
===================================================================
--- sandbox/metz/i.segment.ms/write_output.c 2016-08-02 13:50:46 UTC (rev 69060)
+++ sandbox/metz/i.segment.ms/write_output.c 2016-08-02 19:34:24 UTC (rev 69061)
@@ -79,7 +79,7 @@
struct History hist;
DCELL *min, *max;
- mean_fd = Rast_open_new(globals->out_band, FCELL_TYPE);
+ mean_fd = Rast_open_new(globals->gof, FCELL_TYPE);
meanbuf = Rast_allocate_f_buf();
/* goodness of fit for each cell: 1 = good fit, 0 = bad fit */
@@ -190,11 +190,11 @@
Rast_init_colors(&colors);
Rast_make_grey_scale_fp_colors(&colors, mingood, 1);
- Rast_write_colors(globals->out_band, G_mapset(), &colors);
+ Rast_write_colors(globals->gof, G_mapset(), &colors);
- Rast_short_history(globals->out_band, "raster", &hist);
+ Rast_short_history(globals->gof, "raster", &hist);
Rast_command_history(&hist);
- Rast_write_history(globals->out_band, &hist);
+ Rast_write_history(globals->gof, &hist);
G_free(meanbuf);
@@ -227,7 +227,7 @@
outbuf = G_malloc(sizeof(DCELL) * globals->nbands);
for (n = 0; n < globals->nbands; n++) {
outbuf[n] = Rast_allocate_d_buf();
- G_asprintf(&name[n], "%s%s", globals->Ref.file[n].name, globals->ms_suf);
+ G_asprintf(&name[n], "%s%s", globals->Ref.file[n].name, globals->bsuf);
out_fd[n] = Rast_open_new(name[n], DCELL_TYPE);
}
More information about the grass-commit
mailing list