link_outlines#
- rapidtools.processing.street_instances.link_outlines(held_by: csr_matrix, frame: ndarray, twice: set, min_overlap: float = 0.5) ndarray[source]#
Group outlines of different frames that show the same building.
Two outlines show one building when each holds at least
min_overlapof the other’s points, counting only the points the other frame has inside an outline at all. The pairs are joined strongest first into tracks, and a track never takes two outlines of one frame unless they overlap in the image (twice): a frame shows a building once.- Parameters:
held_by – Sparse
(points, outlines)membership matrix.frame – Frame number of every outline.
twice – Pairs of outlines of one frame that overlap.
min_overlap – Share of each outline’s points the other must hold.
- Returns:
np.ndarray – Track number of every outline.
Example
>>> import numpy as np >>> from scipy import sparse >>> # Two frames. Outlines 0 and 2 hold points 0-19, 1 and 3 hold 20-39. >>> held = np.zeros((40, 4), np.float32) >>> held[:20, [0, 2]] = 1; held[20:, [1, 3]] = 1 >>> frame = np.array([0, 0, 1, 1]) >>> tracks = link_outlines(sparse.csr_matrix(held), frame, set()) >>> bool(tracks[0] == tracks[2]), bool(tracks[1] == tracks[3]) (True, True) >>> len(set(tracks.tolist())) 2