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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 24 13:42:24 PDT 2016


Author: hao2309
Date: 2016-06-24 13:42:24 -0700 (Fri, 24 Jun 2016)
New Revision: 68762

Modified:
   sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c
   sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c
Log:
change L46 of write_output.c

Modified: sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c
===================================================================
--- sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c	2016-06-24 15:56:04 UTC (rev 68761)
+++ sandbox/bo/i.segment.gsoc2016/i.segment/mean_shift.c	2016-06-24 20:42:24 UTC (rev 68762)
@@ -146,8 +146,8 @@
 					}
 					}
 				}
+				}
 			}
-			}
 			if (new_val = 0 || old_val == new_val){
 				if (old_val ==0){
 					class_val+=1;
@@ -162,131 +162,8 @@
 	return TRUE;
 }
 
-// /* /* int clustering(struct globals *globals){
-	// int row, col, n;
-	// int seg_id, class_val;
-	// struct ngbr_stats Rin, Rleft, Rabove;
-	// CELL left_new_val, above_new_val, Rtemp;
-	// double min_val, max_val, old_val, new_val; 
-	// double cluster_threshold, cluster_threshold2;
-	// /*******************************************************
-    // *             Part 2 cluster similar values            *
-    // *         Refer clump.c to cluster super-pixels        *
-    // *******************************************************/
-	
-	// Rleft.mean = G_malloc(globals->datasize);
-	// Rin.mean = G_malloc(globals->datasize);
-	// Rabove.mean = G_malloc(globals->datasize);
-	
-	// G_message(_("Pass 1 of 2 for clustering"));
-	// G_percent_reset();
-	// class_val=0;
-	// cluster_threshold = 0.05;
-	// cluster_threshold2= pow(cluster_threshold ,2);
-	// for (row = globals->row_min; row < globals->row_max; row++) {
-	    // G_percent(row - globals->row_min,
-	              // globals->row_max - globals->row_min, 4);
-	    // for (col = globals->col_min; col < globals->col_max; col++) {
-		// if (!(FLAG_GET(globals->candidate_flag, row, col)))
-		    // continue;
-		// old_val=new_val=0;
-		// /* get the current pixel value */
-		// Segment_get(&globals->bands_seg2, (void *)Rin.mean, row, col);
-		// /* get left pixel value */
-		// if (col == globals->col_min && row == globals->row_min){
-			// class_val+=1;
-			// seg_id=class_val;
-		// }
-		// else if (row == globals->row_min){
-			// /* compare with left value and set if same cluster */
-			// Segment_get(&globals->bands_seg2, (void *)Rleft.mean, row, col-1);
-			// if ((globals->calculate_similarity)(&Rin, &Rleft, globals) <= cluster_threshold2){
-				// G_debug(1, "row: %d, col: %d, left_similarity is: %f",row,col,(globals->calculate_similarity)(&Rin, &Rleft, globals));
-				// Segment_get(&globals->rid_seg, (void *)&left_new_val, row, col-1);
-				// seg_id = left_new_val;
-			// }
-			// /* end compare left */
-			// else{
-				// class_val+=1;
-				// seg_id=class_val;
-			// }
-		// }
-		// else if(col == globals->col_min){
-			// /* compare with above value and set if same cluster */
-			// Segment_get(&globals->bands_seg2, (void *)Rabove.mean, row-1, col);
-			// if ((globals->calculate_similarity)(&Rin, &Rabove, globals) <= cluster_threshold2){
-				// G_debug(1, "row: %d, col: %d, above_similarity is: %f",row,col,(globals->calculate_similarity)(&Rin, &Rabove, globals));
-				// Segment_get(&globals->rid_seg, (void *)&above_new_val, row-1, col);
-				// seg_id = above_new_val;
-			// }
-			// /* end compare above */
-			// else{
-				// class_val+=1;
-				// seg_id=class_val;
-			// }
-		// }
-		// else{
-			// /* compare with left value then above value */
-			// Segment_get(&globals->bands_seg2, (void *)Rleft.mean, row, col-1);
-			// Segment_get(&globals->bands_seg2, (void *)Rabove.mean, row-1, col);
-			// if ((globals->calculate_similarity)(&Rin, &Rleft, globals) <= cluster_threshold2){
-				// G_debug(1, "row: %d, col: %d, left_similarity is: %f",row,col,(globals->calculate_similarity)(&Rin, &Rleft, globals));
-				// Segment_get(&globals->rid_seg, (void *)&left_new_val, row, col-1);
-				// old_val =seg_id = left_new_val;
-			// }
-			// if((globals->calculate_similarity)(&Rin, &Rabove, globals) <= cluster_threshold2){
-				// G_debug(1, "row: %d, col: %d, above_similarity is: %f",row,col,(globals->calculate_similarity)(&Rin, &Rabove, globals));
-				// Segment_get(&globals->rid_seg, (void *)&above_new_val, row-1, col);
-				// seg_id = above_new_val;
-				// if (old_val == 0){
-					// old_val = above_new_val;
-				// }
-				// else{
-					// new_val =  above_new_val;
-					// if (old_val != new_val){
-					// /* conflict! preserve NEW clump ID and change OLD clump ID.
-					// * Must go back to the left in the current row and to the right
-					// * in the previous row to change all the clump values as well.
-					// */
-					// for(n = globals->col_min+1; n< col; n++){
-						// Segment_get(&globals->rid_seg, (void *)&Rtemp, row, n);
-						// if (Rtemp==old_val){
-							// Segment_put(&globals->rid_seg, &new_val, row, n);
-						// }
-					// }
-					/* right of previous row from col + 1 to ncols */
-					// for(n = col+1; n< globals->col_max; n++){
-						// Segment_get(&globals->rid_seg, (void *)&Rtemp, row-1, n);
-						// if (Rtemp==old_val){
-							// Segment_put(&globals->rid_seg, &new_val, row-1, n);
-						// }
-					// }
-				// }
-				// }
-			// }
-			// if (new_val ==0 && old_val ==0){
-				// class_val+=1;
-				// seg_id = class_val;
-			// }
-			// Segment_put(&globals->rid_seg, &seg_id, row, col);
-		// }
-		
-		
-		// G_debug(1, "row: %d, col: %d, Rin is: %f",row,col,Rin.mean[0]);
-		
-		// G_debug(1, "row: %d, col: %d, seg_id is: %d",row,col,seg_id);
-		// G_debug(1, "row: %d, col: %d, cluster_threshold * globals->max_diff is: %f",row,col,pow((cluster_threshold * globals->max_diff),2));
-		// /* compare with above value and set if same cluster */
-		// Segment_put(&globals->rid_seg, &seg_id, row, col);
-		// }
-	// }
 
-	
-	// return TRUE;
-// } */ */
 
-
-
 int mean_shift(struct globals *globals)
 {
     int row, col, t, n1, n2;

Modified: sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c
===================================================================
--- sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c	2016-06-24 15:56:04 UTC (rev 68761)
+++ sandbox/bo/i.segment.gsoc2016/i.segment/write_output.c	2016-06-24 20:42:24 UTC (rev 68762)
@@ -43,8 +43,8 @@
     G_debug(1, "preparing shifted value output raster");
     /* open output raster map */
 	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_%d", globals->ms_suffix, n);
+	G_asprintf(&shifted_out_name, "%s%s", Ref.file[n].name, globals->ms_suffix);
+	
     seg2_fd[n] = Rast_open_new(shifted_out_name, DCELL_TYPE);
 	}
     G_debug(1, "start data transfer from seg2 file to raster");



More information about the grass-commit mailing list