Skip to content

Commit 5e0ee92

Browse files
authored
Ignore 0 in cell match (#350)
Since 0 in labels means that no cell was identified in that pixel, we need to ignore 0 when matching. Otherwise we could have a situation where e.g the cell overlaps 0.55 with 0 and 0.45 with some cell and it would end up unmatched (`ID_coverage` would be 0 and a new track would be initialized)
1 parent 2a408d8 commit 5e0ee92

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pysteps/tracking/tdating.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ def match(cells_ad, labels):
282282
ID_vec = labels[cell_a.y, cell_a.x]
283283
IDs = np.unique(ID_vec)
284284
n_IDs = len(IDs)
285+
if n_IDs == 1 and IDs[0] == 0:
286+
cells_ov.t_ID[ID_a] = 0
287+
continue
288+
IDs = IDs[IDs != 0]
289+
n_IDs = len(IDs)
285290
N = np.zeros(n_IDs)
286291
for n in range(n_IDs):
287292
N[n] = len(np.where(ID_vec == IDs[n])[0])

0 commit comments

Comments
 (0)