[GRASS-SVN] r68675 - sandbox/bo/i.segment.gsoc2016/i.segment

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 12 20:28:34 PDT 2016


Author: hao2309
Date: 2016-06-12 20:28:34 -0700 (Sun, 12 Jun 2016)
New Revision: 68675

Modified:
   sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c
   sandbox/bo/i.segment.gsoc2016/i.segment/open_files.c
Log:
week 3 wrap up codes

Modified: sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c
===================================================================
--- sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c	2016-06-12 20:59:18 UTC (rev 68674)
+++ sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c	2016-06-13 03:28:34 UTC (rev 68675)
@@ -40,7 +40,7 @@
     struct ngbr_stats Rin, Rout, Rwin;
     double weight, sum_of_weights, diff2;
 	double min_val, max_val;
-    
+
 	double ms_spatial_bandwidth = 3;
 	double ms_range_bandwidth = 0.1;
 	
@@ -55,7 +55,7 @@
      * initially, input and output are original band values */
 	/* set the pointers */
 	globals->bands_in = &globals->bands_seg; 
-	globals->bands_out = &globals->bands_seg2;
+	globals->bands_out = &globals->bands_seg;
 	
 	/*window size in pixel number*/
 	window_size = ms_spatial_bandwidth*2+1;
@@ -151,7 +151,7 @@
 
 					/* check range bandwidth */
 					if ((globals->calculate_similarity)(&Rin, &Rwin, globals) <= pow((ms_range_bandwidth * globals->max_diff),2)){
-						/* I think sum_of_weights should be place out of loop because only the same index band pixels will take part in the calculation(Rout.mean[n] += Rwin.mean[n]*weight) */
+						/* I tested sum_of_weights should be place out of loop because only the same index band pixels will take part in the calculation(Rout.mean[n] += Rwin.mean[n]*weight) */
 						sum_of_weights += weight;
 						int n = globals->nbands - 1;
 						do{
@@ -199,16 +199,3 @@
     
     return TRUE;
 }
-
-// /* test out put the result */
-// void print_matrix(struct globals *globals){
-	// int i,j;
-	// struct ngbr_stats R_prt;
-	// R_prt.mean = G_malloc(globals->datasize);
-	// for (i = globals->row_min; i < globals->row_max; i++){
-	    // for (j = globals->col_min; j < globals->col_max; j++) {
-			// Segment_get(&globals->bands_seg, (void *)R_prt.mean,i, j);
-			// G_message(_("\t%.2f"),R_prt.mean[0]);
-		// }
-	// }
-// }
\ No newline at end of file

Modified: sandbox/bo/i.segment.gsoc2016/i.segment/open_files.c
===================================================================
--- sandbox/bo/i.segment.gsoc2016/i.segment/open_files.c	2016-06-12 20:59:18 UTC (rev 68674)
+++ sandbox/bo/i.segment.gsoc2016/i.segment/open_files.c	2016-06-13 03:28:34 UTC (rev 68675)
@@ -131,6 +131,13 @@
 	 scols, inlen, nseg) != 1)
 	G_fatal_error("Unable to create input temporary files");
 	
+	/* add globals->bands_seg2 when using mean shift */
+	// if (globals->method == ORM_MS){
+	// if (Segment_open
+	// (&globals->bands_seg2, G_tempfile(), globals->nrows, globals->ncols, srows,
+	 // scols, inlen, nseg) != 1)
+	// G_fatal_error("Unable to create bands_seg2 input  files");
+	// }
     if (Segment_open
 	(&globals->rid_seg, G_tempfile(), globals->nrows, globals->ncols, srows,
 	 scols, outlen, nseg * 2) != 1)



More information about the grass-commit mailing list