title: Index 3D array by 2D array
body: <p>I have a 3D color image im (shape 512 512 3), and a 2D array mask(512 512). I want to annotate this color image by the mask:</p>
  
  <pre><code>im = im[mask&gt;threshold] + im[mask&lt;threshold] * 0.2 + (255,0,0) * [mask&lt;threshold].
  </code></pre>
  
  <p>How do I write this in Python efficiently?</p>