Skip to content

Commit

Permalink
Ignore 0 in cell match (#350)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
ritvje committed Apr 24, 2024
1 parent 2a408d8 commit 5e0ee92
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pysteps/tracking/tdating.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ def match(cells_ad, labels):
ID_vec = labels[cell_a.y, cell_a.x]
IDs = np.unique(ID_vec)
n_IDs = len(IDs)
if n_IDs == 1 and IDs[0] == 0:
cells_ov.t_ID[ID_a] = 0
continue
IDs = IDs[IDs != 0]
n_IDs = len(IDs)
N = np.zeros(n_IDs)
for n in range(n_IDs):
N[n] = len(np.where(ID_vec == IDs[n])[0])
Expand Down

0 comments on commit 5e0ee92

Please sign in to comment.