merge
dissolve(instances)
Perform a dissolve operation and return a dictionary of merged polygons and their sub-polygons (i.e. from the source list).
Source code in src/tcd_pipeline/scripts/merge.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
filter_centroids(instances, max_overlaps=1)
Filter objects to remove those which contain the centroids of others - this is a simple but fairly effective heuristic to remove "dumbell" shaped predictions which contain multiple individuals.
Source code in src/tcd_pipeline/scripts/merge.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
merge(instances, class_idx, confidence_threshold=0.4, iou_threshold=0.5)
Merge a list of instances.
1) Filter by confidence threshold 2) Dissovle instances to separate overlapping groups 3) For each group, split into polygons following simple heuristics
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instances
|
list[ProcessedInstance]
|
Instance list to consider merging |
required |
class_index
|
int
|
Class filter |
required |
confidence_threshold
|
float
|
Confidence threshold |
0.4
|
iou_threshold(float)
|
Threshold above which to consider a polygon as overlapping |
required |
Returns: list[ProcessedInstance]: List of merged instances
Source code in src/tcd_pipeline/scripts/merge.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
plot_instances(instances)
Plot a list of instances
Source code in src/tcd_pipeline/scripts/merge.py
19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
split(instances, iou_threshold=0.3)
Split a list of instances based on heuristics.
First, instancs are filtered based on whether they contain centroids of other instances. Then, any instances which have a small overlap are considered separate. Instances with a largeer overlap are merged.
This process continues iteratively until all instances have been either merged or split out.
Returns a list of merged instances.
Source code in src/tcd_pipeline/scripts/merge.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|