title: Slicing to change pixel color on an numpy.array image
body: <p>On a previous question I asked how to change colors on an image uploaded on a numpy.array using opencv (BGR format). The goal was to convert any red channel value &lt; 255 to 255.</p>
  
  <p><a href="https://stackoverflow.com/questions/43037582/how-to-optimize-changing-the-value-of-3d-numpy-array-if-meet-a-condition?noredirect=1#comment73162940_43037582">How to optimize changing the value of 3d numpy.array if meet a condition</a></p>
  
  <p>The best answer was:</p>
  
  <pre><code>img[img[:, :, 2] &lt; 255] = 255
  </code></pre>
  
  <p>The point is that I am not understanding what is going on (This is a different question since the previous one was perfectly answered). I understand this part:</p>
  
  <pre><code>img[:, :, 2] &lt; 255
  </code></pre>
  
  <p>Is slicing y, x pixels on the red channel and being compared to 255 value.</p>
  
  <p>However, I do not understand why this is embedded in another array:</p>
  
  <pre><code>img[...] = 255 
  </code></pre>
  
  <p>This has to be read something like: <strong>if  (img[:, :, 2] &lt; 255) then make this pixel-red channel=255</strong> but I don't know how to read the code line to make it sound like that.</p>
  
  <p>Can anyone explain me this code line  very clear so I can modify for other purposes? How should I read it while writing it?</p>