Selaa lähdekoodia

Move cluster code from lib/imagery to lib/cluster
Rename remaining imagery library from libgrass_I to libgrass_imagery



git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31744 15284696-431f-4ddb-bdfa-cd5b030d7da7

Glynn Clements 17 vuotta sitten
vanhempi
commit
aa5ee1d63b

+ 2 - 2
imagery/i.cluster/Makefile

@@ -2,8 +2,8 @@ MODULE_TOPDIR = ../..
 
 PGM = i.cluster
 
-LIBES     = $(IMAGERYLIB) $(GISLIB) $(GMATHLIB)
-DEPENDENCIES= $(IMAGERYDEP) $(GISDEP) $(GMATHDEP)
+LIBES     = $(CLUSTERLIB) $(IMAGERYLIB) $(GISLIB) $(GMATHLIB)
+DEPENDENCIES= $(CLUSTERDEP) $(IMAGERYDEP) $(GISDEP) $(GMATHDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 

+ 20 - 25
imagery/i.cluster/global.h

@@ -13,30 +13,25 @@
 #endif
 
 #include <grass/imagery.h>
+#include <grass/cluster.h>
 
-#ifndef GLOBAL
-# define GLOBAL extern
-#endif
-
-
-
-GLOBAL struct Cluster C;
-GLOBAL struct Signature in_sig;
+extern struct Cluster C;
+extern struct Signature in_sig;
 
-GLOBAL int maxclass ;
-GLOBAL double conv ;
-GLOBAL double sep ;
-GLOBAL int iters ;
-GLOBAL int mcs;
-GLOBAL char *group;
-GLOBAL char *subgroup;
-GLOBAL struct Ref ref;
-GLOBAL char *outsigfile;
-GLOBAL char *insigfile;
-GLOBAL char *reportfile;
-GLOBAL CELL **cell;
-GLOBAL int *cellfd;
-GLOBAL FILE *report;
-GLOBAL int sample_rows, sample_cols;
-GLOBAL int verbose;
-GLOBAL time_t start_time;
+extern int maxclass ;
+extern double conv ;
+extern double sep ;
+extern int iters ;
+extern int mcs;
+extern char *group;
+extern char *subgroup;
+extern struct Ref ref;
+extern char *outsigfile;
+extern char *insigfile;
+extern char *reportfile;
+extern DCELL **cell;
+extern int *cellfd;
+extern FILE *report;
+extern int sample_rows, sample_cols;
+extern int verbose;
+extern time_t start_time;

+ 24 - 3
imagery/i.cluster/main.c

@@ -26,6 +26,27 @@
 #include "local_proto.h"
 
 
+struct Cluster C;
+struct Signature in_sig;
+
+int maxclass ;
+double conv ;
+double sep ;
+int iters ;
+int mcs;
+char *group;
+char *subgroup;
+struct Ref ref;
+char *outsigfile;
+char *insigfile;
+char *reportfile;
+DCELL **cell;
+int *cellfd;
+FILE *report;
+int sample_rows, sample_cols;
+int verbose;
+time_t start_time;
+
 static int interrupted = 0;
 
 
@@ -36,7 +57,7 @@ main (int argc, char *argv[])
     int n;
     int row,nrows;
     int col,ncols;
-    CELL *x;
+    DCELL *x;
     struct Cell_head window;
     FILE *fd;
 
@@ -261,7 +282,7 @@ main (int argc, char *argv[])
     fprintf(report, "\n");
     fflush (report);
 
-    x = (CELL *) G_malloc (ref.nfiles * sizeof(CELL));
+    x = (DCELL *) G_malloc (ref.nfiles * sizeof(DCELL));
 
     I_cluster_begin (&C,ref.nfiles);
 
@@ -272,7 +293,7 @@ main (int argc, char *argv[])
 	if (verbose)
 	    G_percent (row, nrows, 2);
 	for (n=0; n < ref.nfiles; n++)
-	    if (G_get_c_raster_row (cellfd[n], cell[n], row) < 0)
+	    if (G_get_d_raster_row (cellfd[n], cell[n], row) < 0)
 		exit(EXIT_FAILURE);
 	for (col = sample_cols-1; col < ncols; col += sample_cols)
 	{

+ 2 - 2
imagery/i.cluster/open_files.c

@@ -47,11 +47,11 @@ open_files (void)
                 G_program_name());
     }
 
-    cell = (CELL **) G_malloc (ref.nfiles * sizeof (CELL *));
+    cell = (DCELL **) G_malloc (ref.nfiles * sizeof (DCELL *));
     cellfd = (int *) G_malloc (ref.nfiles * sizeof (int));
     for (n=0; n < ref.nfiles; n++)
     {
-	cell[n] = G_allocate_cell_buf();
+	cell[n] = G_allocate_d_raster_buf();
 	name   = ref.file[n].name;
 	mapset = ref.file[n].mapset;
 	if ((cellfd[n] = G_open_cell_old (name, mapset)) < 0)

+ 2 - 1
imagery/i.cluster/print1.c

@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 int print_band_means (FILE *fd, struct Cluster *C)

+ 2 - 1
imagery/i.cluster/print2.c

@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 /* safe to call only during checkpoint(2) and after

+ 2 - 1
imagery/i.cluster/print3.c

@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 /*

+ 2 - 1
imagery/i.cluster/print4.c

@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 #define FMT1 "%g/%d=%.1f"

+ 2 - 1
imagery/i.cluster/print5.c

@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 int 

+ 2 - 1
imagery/i.cluster/print6.c

@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 int print_distribution (FILE *fd, struct Cluster *C)

+ 4 - 1
include/Make/Grass.make.in

@@ -91,6 +91,7 @@ endif
 ARRAYSTATS_LIBNAME        = grass_arraystats
 BITMAP_LIBNAME        = grass_bitmap
 BTREE_LIBNAME         = grass_btree
+CLUSTER_LIBNAME       = grass_cluster
 COORCNV_LIBNAME       = grass_coorcnv
 DATETIME_LIBNAME      = grass_datetime
 DBDIALOG_LIBNAME      = grass_dbdialog
@@ -109,7 +110,7 @@ GPDE_LIBNAME          = grass_gpde
 GPROJ_LIBNAME         = grass_gproj
 IBTREE_LIBNAME        = grass_ibtree
 ICON_LIBNAME          = grass_icon
-IMAGERY_LIBNAME       = grass_I
+IMAGERY_LIBNAME       = grass_imagery
 IORTHO_LIBNAME        = grass_Iortho
 ISMAP_LIBNAME         = grass_ismap
 LINKM_LIBNAME         = grass_linkm
@@ -186,6 +187,7 @@ LRS_LIBNAME           = grass_lrs
 ARRAYSTATSLIB      = -l$(ARRAYSTATS_LIBNAME) $(GISLIB) 
 BITMAPLIB     = -l$(BITMAP_LIBNAME) $(LINKMLIB) 
 BTREELIB      = -l$(BTREE_LIBNAME)
+CLUSTERLIB    = -l$(CLUSTER_LIBNAME) $(IMAGERYLIB) $(GISLIB)
 COORCNVLIB    = -l$(COORCNV_LIBNAME)
 DATETIMELIB   = -l$(DATETIME_LIBNAME)
 DBDIALOGLIB   = -l$(DBDIALOG_LIBNAME)
@@ -283,6 +285,7 @@ ARRAYSTATSDEP    = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(ARRAYSTATS_LIBNAME)$(LIB_SUFFIX
 BITMAPDEP   = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(BITMAP_LIBNAME)$(LIB_SUFFIX)
 BTREEDEP    = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(BTREE_LIBNAME)$(LIB_SUFFIX)
 COORCNVDEP  = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(COORCNV_LIBNAME)$(LIB_SUFFIX)
+CLUSTERDEP  = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(CLUSTER_LIBNAME)$(LIB_SUFFIX)
 DATETIMEDEP = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(DATETIME_LIBNAME)$(LIB_SUFFIX)
 DBDIALOGDEP = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(DBDIALOG_LIBNAME)$(LIB_SUFFIX)
 DISPLAYDEP  = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(DISPLAY_LIBNAME)$(LIB_SUFFIX)

+ 68 - 0
include/cluster.h

@@ -0,0 +1,68 @@
+#ifndef GRASS_CLUSTER_H
+#define GRASS_CLUSTER_H
+
+#include <grass/gis.h>
+#include <grass/imagery.h>
+
+struct Cluster
+{
+    int nbands;
+    int npoints;
+    DCELL **points;
+    int np;
+
+    double *band_sum     ; /* sum over each band */
+    double *band_sum2    ; /* sum of squares over each band */
+
+    int    *class        ; /* class of each point */
+    int    *reclass      ; /* for removing empty classes  */
+    int    *count        ; /* number of points in each class */
+    int    *countdiff    ; /* change in count */
+    double **sum         ; /* sum over band per class */
+    double **sumdiff     ; /* change in sum */
+    double **sum2        ; /* sum of squares per band per class */
+    double **mean        ; /* initial class means */
+    struct Signature S   ; /* final signature(s) */
+
+    int nclasses;
+    int merge1, merge2;
+    int iteration;
+    double percent_stable;
+} ;
+
+/* c_assign.c */
+int I_cluster_assign(struct Cluster *, int *);
+/* c_begin.c */
+int I_cluster_begin(struct Cluster *, int);
+/* c_clear.c */
+int I_cluster_clear(struct Cluster *);
+/* c_distinct.c */
+int I_cluster_distinct(struct Cluster *, double);
+/* c_exec.c */
+int I_cluster_exec(struct Cluster *, int, int, double, double, int, int (*)(), int *);
+/* c_execmem.c */
+int I_cluster_exec_allocate(struct Cluster *);
+int I_cluster_exec_free(struct Cluster *);
+/* c_means.c */
+int I_cluster_means(struct Cluster *);
+/* c_merge.c */
+int I_cluster_merge(struct Cluster *);
+/* c_nclasses.c */
+int I_cluster_nclasses(struct Cluster *, int);
+/* c_point.c */
+int I_cluster_point(struct Cluster *, DCELL *);
+int I_cluster_begin_point_set(struct Cluster *, int);
+int I_cluster_point_part(struct Cluster *, DCELL, int, int);
+int I_cluster_end_point_set(struct Cluster *, int);
+/* c_reassign.c */
+int I_cluster_reassign(struct Cluster *, int *);
+/* c_reclass.c */
+int I_cluster_reclass(struct Cluster *, int);
+/* c_sep.c */
+double I_cluster_separation(struct Cluster *, int, int);
+/* c_sig.c */
+int I_cluster_signatures(struct Cluster *);
+/* c_sum2.c */
+int I_cluster_sum2(struct Cluster *);
+
+#endif

+ 0 - 35
include/imagedefs.h

@@ -101,39 +101,4 @@ int I_put_group_title(const char *, const char *);
 double I_variance(double, double, int);
 double I_stddev(double, double, int);
 
-/* c_assign.c */
-int I_cluster_assign(struct Cluster *, int *);
-/* c_begin.c */
-int I_cluster_begin(struct Cluster *, int);
-/* c_clear.c */
-int I_cluster_clear(struct Cluster *);
-/* c_distinct.c */
-int I_cluster_distinct(struct Cluster *, double);
-/* c_exec.c */
-int I_cluster_exec(struct Cluster *, int, int, double, double, int, int (*)(), int *);
-/* c_execmem.c */
-int I_cluster_exec_allocate(struct Cluster *);
-int I_cluster_exec_free(struct Cluster *);
-/* c_means.c */
-int I_cluster_means(struct Cluster *);
-/* c_merge.c */
-int I_cluster_merge(struct Cluster *);
-/* c_nclasses.c */
-int I_cluster_nclasses(struct Cluster *, int);
-/* c_point.c */
-int I_cluster_point(struct Cluster *, CELL *);
-int I_cluster_begin_point_set(struct Cluster *, int);
-int I_cluster_point_part(struct Cluster *, register CELL, int, int);
-int I_cluster_end_point_set(struct Cluster *, int);
-/* c_reassign.c */
-int I_cluster_reassign(struct Cluster *, int *);
-/* c_reclass.c */
-int I_cluster_reclass(struct Cluster *, int);
-/* c_sep.c */
-double I_cluster_separation(struct Cluster *, int, int);
-/* c_sig.c */
-int I_cluster_signatures(struct Cluster *);
-/* c_sum2.c */
-int I_cluster_sum2(struct Cluster *);
-
 #endif

+ 0 - 26
include/imagery.h

@@ -59,32 +59,6 @@ struct Signature
     } *sig;
 } ;
 
-struct Cluster
-{
-    int nbands;
-    int npoints;
-    CELL **points ;
-    int np;
-
-    double *band_sum     ; /* sum over each band */
-    double *band_sum2    ; /* sum of squares over each band */
-
-    int    *class        ; /* class of each point */
-    int    *reclass      ; /* for removing empty classes  */
-    int    *count        ; /* number of points in each class */
-    int    *countdiff    ; /* change in count */
-    double **sum         ; /* sum over band per class */
-    double **sumdiff     ; /* change in sum */
-    double **sum2        ; /* sum of squares per band per class */
-    double **mean        ; /* initial class means */
-    struct Signature S   ; /* final signature(s) */
-
-    int nclasses;
-    int merge1, merge2;
-    int iteration;
-    double percent_stable;
-} ;
-
 struct SigSet
 {
     int nbands;

+ 1 - 0
lib/Makefile

@@ -21,6 +21,7 @@ SUBDIRS = \
 	gtcltk \
 	form \
 	imagery \
+	cluster \
 	proj \
 	rowio \
 	segment \

+ 10 - 0
lib/cluster/Makefile

@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+LIB_NAME = $(CLUSTER_LIBNAME)
+
+include $(MODULE_TOPDIR)/include/Make/Lib.make
+
+EXTRA_LIBS = $(IMAGERYLIB) $(GMATHLIB) $(GISLIB)
+
+default: lib
+

+ 3 - 4
lib/imagery/c_assign.c

@@ -1,6 +1,5 @@
 #include <math.h>
-
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_assign ( struct Cluster *C, int *interrupted)
 {
@@ -25,7 +24,7 @@ fprintf (stderr,"I_cluster_assign(npoints=%d,nclasses=%d,nbands=%d)\n",
 	    d = 0.0;
 	    for (band = 0; band < C->nbands; band++)
 	    {
-		q = (double) C->points[band][p];
+		q = C->points[band][p];
 		q -= C->mean[band][c];
 		d += q*q;
 	    }
@@ -38,7 +37,7 @@ fprintf (stderr,"I_cluster_assign(npoints=%d,nclasses=%d,nbands=%d)\n",
 	C->class[p] = class;
 	C->count[class]++;
 	for (band = 0; band < C->nbands; band++)
-	    C->sum[band][class] += (double) C->points[band][p] ;
+	    C->sum[band][class] += C->points[band][p] ;
     }
 
 	return 0;

+ 3 - 3
lib/imagery/c_begin.c

@@ -1,5 +1,5 @@
 #include <stdlib.h>
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 /****************************************************************
  * I_cluster_begin (C,nbands)
  *
@@ -44,7 +44,7 @@ int I_cluster_begin(struct Cluster *C,int nbands)
     sprintf (C->S.title, "produced by i.cluster");
 
 /* allocate the data (points) arrays */
-    C->points = (CELL **) malloc (C->nbands * sizeof (CELL *));
+    C->points = (DCELL **) malloc (C->nbands * sizeof (DCELL *));
     if (C->points == NULL)
 	return -1;
     for (band = 0; band < C->nbands; band++)
@@ -53,7 +53,7 @@ int I_cluster_begin(struct Cluster *C,int nbands)
     C->np = 128 ;
     for (band = 0; band < C->nbands; band++)
     {
-	C->points[band] = (CELL *) malloc (C->np * sizeof (CELL)) ;
+	C->points[band] = (DCELL *) malloc (C->np * sizeof (DCELL)) ;
 	if (C->points[band] == NULL)
 	    return -1;
     }

+ 1 - 1
lib/imagery/c_clear.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 int I_cluster_clear (struct Cluster *C)
 {
     C->points = NULL;

+ 1 - 2
lib/imagery/c_distinct.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_distinct(struct Cluster *C, double separation)
 {
@@ -6,7 +6,6 @@ int I_cluster_distinct(struct Cluster *C, double separation)
     int distinct;
     double dmin;
     double dsep;
-    double I_cluster_separation();
 
 /* compute sum of squares for each class */
     I_cluster_sum2 (C);

+ 1 - 1
lib/imagery/c_exec.c

@@ -17,7 +17,7 @@
  *  -2 interrupted
  *   1 not enough data points
  *************************************************************/
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_exec (
     struct Cluster *C,int maxclass,int iterations,

+ 1 - 1
lib/imagery/c_execmem.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_exec_allocate(struct Cluster *C)
 {

+ 5 - 5
lib/imagery/c_means.c

@@ -1,5 +1,5 @@
-#include <grass/imagery.h>
 #include <math.h>
+#include <grass/cluster.h>
 
 int I_cluster_means (struct Cluster *C)
 {
@@ -13,10 +13,10 @@ fprintf(stderr,"I_cluster_means(nbands=%d,nclasses=%d)\n",C->nbands, C->nclasses
 */
     for (band = 0; band < C->nbands; band++)
     {
-	s = (double) C->band_sum[band] ;
-	m = s / (double) C->npoints;
-	v = (double) C->band_sum2[band]  - s * m;
-	v = sqrt (v / (double) (C->npoints - 1));
+	s = C->band_sum[band] ;
+	m = s / C->npoints;
+	v = C->band_sum2[band]  - s * m;
+	v = sqrt(v / (C->npoints - 1));
 	for (class = 0; class < C->nclasses; class++)
 	    C->mean[band][class] = m;
 	if (C->nclasses > 1)

+ 1 - 1
lib/imagery/c_merge.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_merge (struct Cluster *C)
 {

+ 1 - 1
lib/imagery/c_nclasses.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_nclasses (struct Cluster *C,int minsize)
 {

+ 11 - 11
lib/imagery/c_point.c

@@ -1,7 +1,7 @@
 /****************************************************************
  * I_cluster_point (C,x)
  *     struct Cluster *C;
- *     CELL *x;
+ *     DCELL *x;
  *
  * adds the point x to the list of data points to be "clustered"
  *
@@ -16,17 +16,17 @@
  * note: if all values in x are zero, the point is rejected
  ***************************************************************/
 
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 static int extend(struct Cluster *,int);
 static int all_zero(struct Cluster *,int);
 
-int I_cluster_point( struct Cluster *C, CELL *x)
+int I_cluster_point( struct Cluster *C, DCELL *x)
 {
     int band;
 
 /* reject points which contain nulls in one of the bands */
     for (band = 0; band < C->nbands; band++)
-	if (G_is_c_null_value(&x[band])) return 1; /* fixed 11/99 Agus Carr */
+	if (G_is_d_null_value(&x[band])) return 1; /* fixed 11/99 Agus Carr */
 /*
     if (band >= C->nbands)
 	return 1;
@@ -41,7 +41,7 @@ int I_cluster_point( struct Cluster *C, CELL *x)
     {
 	register double z;
 
- /*       if(G_is_c_null_value(&x[band])) continue;*/
+ /*       if(G_is_d_null_value(&x[band])) continue;*/
 	z = C->points[band][C->npoints] = x[band];
 	C->band_sum[band]  += z;
 	C->band_sum2[band] += z*z;
@@ -56,13 +56,13 @@ int I_cluster_begin_point_set (struct Cluster *C, int n)
 }
 
 int I_cluster_point_part (
-    struct Cluster *C,register CELL x,int band, int n)
+    struct Cluster *C, DCELL x, int band, int n)
 {
-    CELL tmp=x;
-    if(G_is_c_null_value(&tmp)) return 1;
+    DCELL tmp=x;
+    if(G_is_d_null_value(&tmp)) return 1;
     C->points[band][C->npoints+n] = x;
-    C->band_sum[band]  += (double) x;
-    C->band_sum2[band] += (double) x*x;
+    C->band_sum[band]  += x;
+    C->band_sum2[band] += x*x;
 
     return 0;
 }
@@ -106,7 +106,7 @@ static int extend(struct Cluster *C, int n)
 	C->np += 128;
 	for (band = 0; band < C->nbands; band++)
 	{
-	    C->points[band] = (CELL *) I_realloc (C->points[band], C->np * sizeof (CELL)) ;
+	    C->points[band] = (DCELL *) I_realloc (C->points[band], C->np * sizeof(DCELL)) ;
 	    if (C->points[band] == NULL)
 		return 0;
 	}

+ 3 - 3
lib/imagery/c_reassign.c

@@ -1,10 +1,10 @@
 #include <math.h>
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_reassign(struct Cluster *C, int *interrupted)
 {
     double min,d,z;
-    int q;
+    double q;
     int c,np;
     int old;
     int p, band, class;
@@ -60,7 +60,7 @@ int I_cluster_reassign(struct Cluster *C, int *interrupted)
 
 	    for (band = 0; band < C->nbands; band++)
 	    {
-		q = (int) C->points[band][p];
+		q = C->points[band][p];
 		C->sumdiff[band][class] += q;
 		C->sumdiff[band][old] -= q;
 	    }

+ 1 - 1
lib/imagery/c_reclass.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 int I_cluster_reclass(struct Cluster *C, int minsize)
 {

+ 6 - 6
lib/imagery/c_sep.c

@@ -1,4 +1,5 @@
-#include <grass/imagery.h>
+#include <math.h>
+#include <grass/cluster.h>
 
 #define FAR ((double) -1.0)
 
@@ -12,7 +13,6 @@ double I_cluster_separation(struct Cluster *C,int class1,int class2)
     double n1,n2;
     double m1,m2;
     double s1,s2;
-    double sqrt();
 
     if (C->count[class1] < 2) return FAR;
     if (C->count[class2] < 2) return FAR;
@@ -23,8 +23,8 @@ double I_cluster_separation(struct Cluster *C,int class1,int class2)
     a1 = a2 = 0.0;
     for (band = 0; band < C->nbands; band++)
     {
-	s1 = (double) C->sum[band][class1] ;
-	s2 = (double) C->sum[band][class2] ;
+	s1 = C->sum[band][class1] ;
+	s2 = C->sum[band][class2] ;
 	m1 = s1 / n1;
 	m2 = s2 / n2;
 	q = m1 - m2;
@@ -32,12 +32,12 @@ double I_cluster_separation(struct Cluster *C,int class1,int class2)
 	d += q;
 
 
-	var = (double) C->sum2[band][class1] - (s1 * m1) ;
+	var = C->sum2[band][class1] - (s1 * m1) ;
 	var /= n1 - 1;
 	if (var)
 	    a1 += q/var;
 
-	var = (double) C->sum2[band][class2] - (s2 * m2) ;
+	var = C->sum2[band][class2] - (s2 * m2) ;
 	var /= n2 - 1;
 	if (var)
 	    a2 += q/var;

+ 2 - 2
lib/imagery/c_sig.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 int I_cluster_signatures ( struct Cluster *C)
 {
     int c, p, band1, band2;
@@ -47,7 +47,7 @@ if (c >= C->nclasses)
 	dn = n = C->S.sig[c].npoints = C->count[c];
 	if (n == 0) dn = 1.0;
 	for (band1 = 0; band1 < C->nbands; band1++)
-	    C->S.sig[c].mean[band1] = (double) C->sum[band1][c] / dn;
+	    C->S.sig[c].mean[band1] = C->sum[band1][c] / dn;
 	dn = n = C->count[c] - 1;
 	if (n < 1)
 	    continue;

+ 2 - 2
lib/imagery/c_sum2.c

@@ -1,4 +1,4 @@
-#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 /* compute sum of squares for each class */
 int I_cluster_sum2(struct Cluster *C)
@@ -20,7 +20,7 @@ fprintf (stderr, "I_cluster_sum2(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoint
 	    continue;
 	for (band = 0; band < C->nbands; band++)
 	{
-	    q = (double)C->points[band][p];
+	    q = C->points[band][p];
 	    C->sum2[band][class] += q*q;
 	}
     }