GRASS GIS 8 Programmer's Manual 8.3.2(2024)-exported
Loading...
Searching...
No Matches
c_distinct.c
Go to the documentation of this file.
1/*!
2 \file cluster/c_distinct.c
3
4 \brief Cluster library - Distinct value
5
6 (C) 2001-2009 by the GRASS Development Team
7
8 This program is free software under the GNU General Public License
9 (>=v2). Read the file COPYING that comes with GRASS for details.
10
11 \author Original author CERL
12 */
13
14#include <grass/cluster.h>
15
16/*!
17 \brief Get distinct value
18
19 \param C pointer to Cluster structure
20 \param separation separation value
21
22 \return distinction value
23 */
24int I_cluster_distinct(struct Cluster *C, double separation)
25{
26 int class1, class2;
27 int distinct;
28 double dmin;
29 double dsep;
30
31 /* compute sum of squares for each class */
33
34 /* find closest classes */
35 distinct = 1;
36 dmin = separation;
37 for (class1 = 0; class1 < (C->nclasses - 1); class1++) {
38 if (C->count[class1] < 2)
39 continue;
40 for (class2 = class1 + 1; class2 < C->nclasses; class2++) {
41 if (C->count[class2] < 2)
42 continue;
43 dsep = I_cluster_separation(C, class1, class2);
44
45 if (dsep >= 0.0 && dsep < dmin) {
46 distinct = 0;
47 C->merge1 = class1;
48 C->merge2 = class2;
49 dmin = dsep;
50 }
51 }
52 }
53
54 return distinct;
55}
int I_cluster_distinct(struct Cluster *C, double separation)
Get distinct value.
Definition c_distinct.c:24
double I_cluster_separation(struct Cluster *C, int class1, int class2)
?
Definition c_sep.c:26
int I_cluster_sum2(struct Cluster *C)
Compute sum of squares for each class.
Definition c_sum2.c:23