-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClusterSplitter.java
More file actions
47 lines (42 loc) · 1.16 KB
/
ClusterSplitter.java
File metadata and controls
47 lines (42 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
public class ClusterSplitter {
private Cluster father, lowChild, highChild;
private int n, m;
ClusterSplitter(Cluster c)
{
father = c;
n = father.getNumberOfRows();
m = father.getNumberOfColumns();
}
public void split()
{
lowChild = new Cluster(n, m);
highChild = new Cluster(n, m);
ImageVector low = new ImageVector(n, m);
ImageVector high = new ImageVector(n, m);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
low.set(i,j, Math.max(0, father.get(i, j) - 1));
high.set(i, j, Math.min(255, father.get(i, j) + 1));
}
}
for (ImageVector v : father.getVectors())
{
if (low.getDistance(v) < high.getDistance(v))
lowChild.addVector(v);
else
highChild.addVector(v);
}
lowChild.calcRep();
highChild.calcRep();
}
public Cluster getLowChild()
{
return lowChild;
}
public Cluster getHighChild()
{
return highChild;
}
}