title: How to convert slice object to boolean index?
body: <h2>TL;DR:</h2>
  <p>Knowing the value of <code>NUM_ROWS</code>, <code>rmin</code> and <code>rmax</code>, how do I construct a bool array <code>my_idx</code> such that <code>np.arange(NUM_ROWS)[my_idx] == np.arange(NUM_ROWS)[rmin:rmax]</code>? Can the construction operation be broadcasted, if <code>rmin</code> and <code>rmax</code> are arrays ad I'm interested in all slices <code>[slice(from, to) for from, to in zip(rmin, rmax)]</code>?</p>
  <hr />
  <h2>Long version with details</h2>
  <p>I have an array of polygons in a 2D image and I want to find rows and columns of the image that don't contain a polygon. In order to do this fast, I'm trying to vectorize the code as much as possible.</p>
  <p>I calculate the extreme points of each polygon on both dimension and obtain for each polygon the <code>min_row</code>, <code>min_col</code>, <code>max_row</code> and <code>max_col</code> values. Let's consider just the rows (as for the columns it 's the same algorithm) and assume that, for example, these are the values I obtain for two polygons:</p>
  <pre><code>NUM_ROWS = 10
  # Two intervals: slice(1,5) and slice(7,8)
  row_mins = np.array([1, 7], dtype=np.int32)
  row_maxs = np.array([5, 8], dtype=np.int32)
  
  </code></pre>
  <p>I want now to merge the intervals in a way equivalent to:</p>
  <pre><code>row_mask = np.zeros(NUM_ROWS)
  for rmin, rmax in zip(row_mins, row_maxs):
    row_mask[rmin:rmax] = 1
  </code></pre>
  <p>however, it should avoid the for loop and repeated setting of values in row_mask.
  I thought of doing this by turning each range into a bool array and using <code>np.logical_or.reduce()</code>, but I can't find a way to generate the bool array equivalent to the <code>[rmin:rmax]</code> index.
  Is there a way to convert a slice object to a bool index?</p>