title: Applying a 2D numpy mask to grayscale image
body: <p>I have a 256×256 px 2D mask with pixel values of either 0 or 255, and a matching grayscale image. Both have shapes (256, 256).</p>
  
  <p>I'd like to apply the mask on the grayscale image so the resulting image only contains pixels from the original grayscale image, where corresponding mask values are 255 (the original grayscale pixel values should be preserved).</p>
  
  <p>I'm not being able to do this using</p>
  
  <pre><code>img_clean = img_grayscale[mask]
  </code></pre>
  
  <p>as it adds a new dimension to the array (as mentioned in numpy's docs).</p>
  
  <p>How do I resolve this?</p>