GRASS GIS 7 Programmer's Manual  7.0.3(2016)-r00000
c_reclass.c
Go to the documentation of this file.
1 
14 #include <grass/cluster.h>
15 
25 int I_cluster_reclass(struct Cluster *C, int minsize)
26 {
27  int band, c, hole, move, p;
28 
29  for (c = 0; c < C->nclasses; c++)
30  C->reclass[c] = c;
31 
32  /* find first `empty' class */
33  for (hole = 0; hole < C->nclasses; hole++)
34  if (C->count[hole] < minsize)
35  break;
36 
37  /* if none, just return */
38  if (hole >= C->nclasses)
39  return 1;
40 
41  for (move = hole; move < C->nclasses; move++)
42  if (C->count[move] >= minsize) {
43  C->reclass[move] = hole;
44  C->count[hole] = C->count[move];
45  for (band = 0; band < C->nbands; band++)
46  C->sum[band][hole] = C->sum[band][move];
47  hole++;
48  }
49  else
50  C->reclass[move] = -1; /* eliminate this class */
51 
52  for (p = 0; p < C->npoints; p++)
53  C->class[p] = C->reclass[C->class[p]];
54  C->nclasses = hole;
55 
56  return 0;
57 }
int I_cluster_reclass(struct Cluster *C, int minsize)
Reclass data.
Definition: c_reclass.c:25