[GRASS-SVN] r68793 - sandbox/bo/i.segment.gsoc2016/i.segment
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 28 11:51:55 PDT 2016
Author: hao2309
Date: 2016-06-28 11:51:55 -0700 (Tue, 28 Jun 2016)
New Revision: 68793
Modified:
sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c
sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c
Log:
changed read color form map and alpha square
Modified: sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c
===================================================================
--- sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c 2016-06-28 15:51:24 UTC (rev 68792)
+++ sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c 2016-06-28 18:51:55 UTC (rev 68793)
@@ -262,7 +262,7 @@
int n_changes, window_size;
int window_row_north, window_row_south, window_col_west,window_col_east, current_window_row, current_window_col;
struct ngbr_stats Rin, Rout, Rwin;
- double weight, sum_of_weights, diff2;
+ double weight, sum_of_weights, diff2, alpha2;
SEGMENT *bands_tmp;
@@ -272,7 +272,8 @@
Rin.mean = G_malloc(globals->datasize);
Rwin.mean = G_malloc(globals->datasize);
Rout.mean = G_malloc(globals->datasize);
-
+ alpha2 = globals->alpha * globals->alpha;
+
/* TODO: need another segment structure holding output
* initially, input and output are original band values */
/* set the pointers */
@@ -402,7 +403,7 @@
Segment_get(&globals->bands_seg2, (void *)Rout.mean,row, col);
// G_message(_("row: %d, col: %d, Rout.mean of seg2 is: %f"),row,col,Rout.mean[0]);
diff2 = (globals->calculate_similarity)(&Rin, &Rout, globals);
- if (diff2 > globals->alpha)
+ if (diff2 > alpha2)
n_changes++;
@@ -416,7 +417,7 @@
G_message(_("Mean shift converged after %d iterations"), t);
- if (clustering2(globals) != TRUE)
+ if (clustering(globals) != TRUE)
G_fatal_error(_("Error in clustering segments"));
/*******************************************************
* Part 3 identify connected components *
Modified: sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c
===================================================================
--- sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c 2016-06-28 15:51:24 UTC (rev 68792)
+++ sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c 2016-06-28 18:51:55 UTC (rev 68793)
@@ -88,11 +88,11 @@
}
for (n=0;n<globals->nbands; n++){
- G_asprintf(&shifted_out_name, "%s_%s", Ref.file[n].name, globals->ms_suffix);
+ G_asprintf(&shifted_out_name, "%s%s", Ref.file[n].name, globals->ms_suffix);
/* set colors */
Rast_init_colors(&colors);
Rast_read_colors(Ref.file[n].name,Ref.file[n].mapset, &colors);
- Rast_write_colors(shifted_out_name, Ref.file[n].mapset, &colors);
+ Rast_write_colors(shifted_out_name, G_mapset(), &colors);
Rast_short_history(shifted_out_name, "raster", &hist);
More information about the grass-commit
mailing list