[GRASS-SVN] r69017 - sandbox/metz/i.segment.ms

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 21 12:16:13 PDT 2016


Author: mmetz
Date: 2016-07-21 12:16:12 -0700 (Thu, 21 Jul 2016)
New Revision: 69017

Modified:
   sandbox/metz/i.segment.ms/cluster.c
Log:
sandbox i.segment.ms: fix NULL check for clustering

Modified: sandbox/metz/i.segment.ms/cluster.c
===================================================================
--- sandbox/metz/i.segment.ms/cluster.c	2016-07-21 17:33:41 UTC (rev 69016)
+++ sandbox/metz/i.segment.ms/cluster.c	2016-07-21 19:16:12 UTC (rev 69017)
@@ -31,8 +31,8 @@
 #define INCR 1024
 
 /* defeats the purpose of padding ... */
-#define CISNULL(c) (((c) == 0 || (c) == ncols + 1 ? 1 : (FLAG_GET(globals->null_flag, row, (c - 1)))))
-#define CISNULLPREV(c) (row == 0 ? 1 : CISNULL(c))
+#define CISNULL(r, c) (((c) == 0 || (c) == ncols + 1 ? 1 : \
+                       (FLAG_GET(globals->null_flag, (r), (c - 1)))))
 
 
 CELL cluster_bands(struct globals *globals)
@@ -142,7 +142,7 @@
 	    Segment_get(globals->bands_out, (void *)cur_in[col], row, col - 1);
 	    Ri.mean = cur_in[col];
 
-	    if (CISNULL(col)) {
+	    if (CISNULL(row, col)) {
 		cur_clump[col] = 0;
 		continue;
 	    }
@@ -226,7 +226,8 @@
 	    Rk.mean = cur_in[col - 1];
 
 	    /* same clump as to the left */
-	    if (!CISNULL(col - 1) && globals->calculate_similarity(&Ri, &Rk, globals) <= hspec2ad) {
+	    if (!CISNULL(row, col - 1) &&
+	        globals->calculate_similarity(&Ri, &Rk, globals) <= hspec2ad) {
 		OLD = cur_clump[col] = cur_clump[col - 1];
 	    }
 
@@ -236,7 +237,8 @@
 		bcol = col + 1;
 		do {
 		    Rk.mean = prev_in[bcol];
-		    if (!CISNULLPREV(bcol) && globals->calculate_similarity(&Ri, &Rk, globals) <= hspec2ad) {
+		    if (row > 0 && !CISNULL(row - 1, bcol) &&
+		        globals->calculate_similarity(&Ri, &Rk, globals) <= hspec2ad) {
 			cur_clump[col] = *temp_clump;
 			if (OLD == 0) {
 			    OLD = *temp_clump;
@@ -289,7 +291,8 @@
 		/* check above */
 		Rk.mean = prev_in[col];
 
-		if (!CISNULLPREV(col) && globals->calculate_similarity(&Ri, &Rk, globals) <= hspec2ad) {
+		if (row > 0 && !CISNULL(row - 1, col) &&
+		    globals->calculate_similarity(&Ri, &Rk, globals) <= hspec2ad) {
 		    temp_clump = prev_clump + col;
 		    cur_clump[col] = *temp_clump;
 		    if (OLD == 0) {



More information about the grass-commit mailing list