title: How to modify each element of a numpy multidimentional array conditionally?
body: <p>I converted an image into a gray scale numpy array using opencv:</p>
  
  <pre><code>im_g=cv2.imread("smallgray.png",0)
  print(im_g)
  
  [[187 158 104 121 143]
   [198 125 255 255 147]
   [209 134 255  97 182]]
  </code></pre>
  
  <p>I want to darken the image for those values that are higher than 200 for example, being 255 white and 0 black. If I do this I get the correct result:</p>
  
  <pre><code>im_g[im_g&gt;200] = 150
  print(im_g)
  
  [[187 158 104 121 143]
   [198 125 150 150 147]
   [150 134 150  97 182]]
  </code></pre>
  
  <p>But my question is, if I don't want to use a constant (like 150 in the example) and instead perform some calculation on the current element, how do I refer to that element??</p>
  
  <p>Thanks in advance</p>