14#include <grass/raster.h>
15#include <grass/cluster.h>
17static int extend(
struct Cluster *,
int);
18static int all_zero(
struct Cluster *,
int);
37 for (band = 0; band < C->nbands; band++)
38 if (Rast_is_d_null_value(&
x[band]))
50 for (band = 0; band < C->nbands; band++) {
54 z = C->points[band][C->npoints] =
x[band];
55 C->band_sum[band] += z;
56 C->band_sum2[band] += z * z;
73 return extend(C, n) ? 0 : -1;
92 if (Rast_is_d_null_value(&tmp))
94 C->points[band][C->npoints + n] =
x;
95 C->band_sum[band] +=
x;
96 C->band_sum2[band] +=
x *
x;
116 for (next = cur; next < n; next++) {
117 if (!all_zero(C, next)) {
119 for (band = 0; band < C->nbands; band++)
120 C->points[band][cur] = C->points[band][next];
124 return C->npoints = cur;
127static int all_zero(
struct Cluster *C,
int i)
131 for (band = 0; band < C->nbands; band++)
132 if (C->points[band][i])
137static int extend(
struct Cluster *C,
int n)
141 while ((C->npoints + n) > C->np) {
143 for (band = 0; band < C->nbands; band++) {
145 (DCELL *)I_realloc(C->points[band], C->np *
sizeof(DCELL));
146 if (C->points[band] ==
NULL)
int I_cluster_end_point_set(struct Cluster *C, int n)
?
int I_cluster_point_part(struct Cluster *C, DCELL x, int band, int n)
?
int I_cluster_begin_point_set(struct Cluster *C, int n)
Begin point set.
int I_cluster_point(struct Cluster *C, DCELL *x)
Adds the point x to the list of data points to be "clustered".