I want to assign a value to some segments of an array. I've got indexes of the segments as tuples (start_idx, end_idx). Segments may overlay or be sub-segments of each other.
a = np.zeros(12)
segments = np.array([(0, 3), (1, 2), (6, 8), (8, 10)])
a[segments] = 1
The results is:
a
>> array([1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0])
How can I mask all segments to get this output:
a
>> array([1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0])