[GRASS-SVN] r54323 - grass/trunk/imagery/i.smap

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 17 05:58:20 PST 2012


Author: mmetz
Date: 2012-12-17 05:58:20 -0800 (Mon, 17 Dec 2012)
New Revision: 54323

Modified:
   grass/trunk/imagery/i.smap/interp.c
   grass/trunk/imagery/i.smap/region.h
   grass/trunk/imagery/i.smap/segment.c
Log:
i.smap: add goodness of fit for MLE

Modified: grass/trunk/imagery/i.smap/interp.c
===================================================================
--- grass/trunk/imagery/i.smap/interp.c	2012-12-17 13:38:19 UTC (rev 54322)
+++ grass/trunk/imagery/i.smap/interp.c	2012-12-17 13:58:20 UTC (rev 54323)
@@ -15,7 +15,7 @@
 static void print_alpha(double *);
 static void interp(unsigned char **, struct Region *, unsigned char **,
 		   LIKELIHOOD ***, int, double *, int, double ***, int, float **);
-void MLE(unsigned char **, LIKELIHOOD ***, struct Region *, int);
+void MLE(unsigned char **, LIKELIHOOD ***, struct Region *, int, float **);
 static int up_char(int, int, struct Region *, unsigned char **,
 		   unsigned char **);
 
@@ -46,7 +46,7 @@
 			    LIKELIHOOD **** ll_pym,	/* pyramid of class statistics */
 			    int M,	                /* number of classes */
 			    double *alpha_dec,	        /* decimation parameters returned by seq_MAP */
-			    float **goodness           /* goodness of fit */
+			    float **goodness            /* goodness of fit */
     )
 {
     int j, k;			/* loop index */
@@ -89,7 +89,7 @@
     }
 
     /* Compute Maximum Likelihood estimate at coarsest resolution */
-    MLE(sf_pym[D], ll_pym[D], &(regionary[D]), M);
+    MLE(sf_pym[D], ll_pym[D], &(regionary[D]), M, NULL);
 
     /* Initialize the transition parameters */
     alpha[0] = 0.5 * (3.0 / 7.0);
@@ -201,7 +201,7 @@
 		      int period,	/* sampling period of interpolation */
 		      double ***N,	/* transition probability statistics; N[2][3][2] */
 		      int statflag,	/* compute transition statistics if == 1 */
-		      float **goodness /* cost of best class */
+		      float **goodness  /* cost of best class */
     )
 {
     int i, j;			/* pixel index */
@@ -292,7 +292,8 @@
 	    unsigned char **sf,	/* segmentation classes */
 	    LIKELIHOOD *** ll,	/* texture statistics */
 	    struct Region *region,	/* image region */
-	    int M		/* number of classes */
+	    int M,		/* number of classes */
+	    float **goodness    /* goodness of fit */
     )
 {
     int i, j, m, best;
@@ -309,6 +310,8 @@
 		}
 	    }
 	    sf[i][j] = best;
+	    if (goodness)
+		goodness[i][j] = max;
 	}
 }
 

Modified: grass/trunk/imagery/i.smap/region.h
===================================================================
--- grass/trunk/imagery/i.smap/region.h	2012-12-17 13:38:19 UTC (rev 54322)
+++ grass/trunk/imagery/i.smap/region.h	2012-12-17 13:58:20 UTC (rev 54323)
@@ -22,7 +22,7 @@
 /* interp.c */
 void seq_MAP(unsigned char ***, struct Region *, LIKELIHOOD ****, int,
 	     double *, float **);
-void MLE(unsigned char **, LIKELIHOOD ***, struct Region *, int);
+void MLE(unsigned char **, LIKELIHOOD ***, struct Region *, int, float **);
 
 /* reg_util.c */
 int levels_reg(struct Region *);

Modified: grass/trunk/imagery/i.smap/segment.c
===================================================================
--- grass/trunk/imagery/i.smap/segment.c	2012-12-17 13:38:19 UTC (rev 54322)
+++ grass/trunk/imagery/i.smap/segment.c	2012-12-17 13:58:20 UTC (rev 54323)
@@ -110,7 +110,7 @@
 	extract(img, &region, ll_pym[0], S);
 
 	if (ml)
-	    MLE(sf_pym[0], ll_pym[0], &region, nclasses);
+	    MLE(sf_pym[0], ll_pym[0], &region, nclasses, goodness);
 	else {
 	    for (i = 0; i < D; i++)
 		alpha_dec[i] = 1.0;



More information about the grass-commit mailing list