fix removal of closeby clusters
Browse files- clustering.py +9 -1
clustering.py
CHANGED
|
@@ -47,6 +47,7 @@ def get_centroids(image : np.ndarray, image_threshold = 20,
|
|
| 47 |
|
| 48 |
|
| 49 |
centroids = []
|
|
|
|
| 50 |
|
| 51 |
# apply the threshold to identify regions of "dark" pixels
|
| 52 |
# the result is a binary mask (true/false) whether a given pixel is above or below the threshold
|
|
@@ -98,6 +99,13 @@ def get_centroids(image : np.ndarray, image_threshold = 20,
|
|
| 98 |
proximity_tree = KDTree(centroids)
|
| 99 |
pairs = proximity_tree.query_pairs(filter_radius)
|
| 100 |
for p in pairs:
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
return centroids
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
centroids = []
|
| 50 |
+
#print('Threshold: ', image_threshold)
|
| 51 |
|
| 52 |
# apply the threshold to identify regions of "dark" pixels
|
| 53 |
# the result is a binary mask (true/false) whether a given pixel is above or below the threshold
|
|
|
|
| 99 |
proximity_tree = KDTree(centroids)
|
| 100 |
pairs = proximity_tree.query_pairs(filter_radius)
|
| 101 |
for p in pairs:
|
| 102 |
+
#print('pair: ', p, ' p[0]: ', p[0], ' p[1]:', p[1])
|
| 103 |
+
#print('coords: ', proximity_tree.data[p[0]], ' ', proximity_tree.data[p[1]])
|
| 104 |
+
coords_to_remove = [proximity_tree.data[p[0]][0], proximity_tree.data[p[0]][1]]
|
| 105 |
+
try:
|
| 106 |
+
idx = centroids.index(coords_to_remove)
|
| 107 |
+
centroids.pop(idx)
|
| 108 |
+
except ValueError:
|
| 109 |
+
pass
|
| 110 |
|
| 111 |
return centroids
|