Jelajahi Sumber

i.segment: fix more special cases

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57201 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 11 tahun lalu
induk
melakukan
8ad1e70655
2 mengubah file dengan 7 tambahan dan 3 penghapusan
  1. 2 3
      imagery/i.segment/create_isegs.c
  2. 5 0
      imagery/i.segment/open_files.c

+ 2 - 3
imagery/i.segment/create_isegs.c

@@ -309,10 +309,9 @@ int region_growing(struct globals *globals)
 		G_debug(4, "Rk is now complete");
 
 		if (Rk.id == 0) {
-		    /* this can only happen if only one segment is left */
+		    /* this can only happen if the segment is surrounded by NULL data */
 		    G_debug(4, "Segment had no valid neighbors");
-		    pathflag = FALSE;
-		    Ri.count = 0;
+		    continue;
 		}
 
 		if (/* !(t & 1) && */ Ri_nn == 1 &&

+ 5 - 0
imagery/i.segment/open_files.c

@@ -294,6 +294,8 @@ int open_files(struct globals *globals)
 	load_seeds(globals, srows, scols, nseg);
     }
 
+    G_debug(1, "Number of initial regions: %d", globals->n_regions);
+
     G_free(inbuf);
     G_free(in_fd);
     G_free(fp_range);
@@ -368,6 +370,7 @@ static int load_seeds(struct globals *globals, int srows, int scols, int nseg)
 		    if (segment_put(&globals->rid_seg, &sneg, row, col) != 1)
 			G_fatal_error(_("Unable to write to temporary file"));
 		    sneg--;
+		    globals->n_regions--;
 		}
 		else {
 		    Ri.row = row;
@@ -494,6 +497,8 @@ static int read_seed(struct globals *globals, SEGMENT *seeds_seg, struct rc *Ri,
     else {
 	update_band_vals(Ri->row, Ri->col, &(globals->rs), globals);
     }
+    if (globals->rs.count > 1)
+	globals->n_regions -= (globals->rs.count - 1);
 
     return 1;
 }