title: How to fusion two (or more) arrays without losing values in numpy
body: <p>Following the example given in <a href="https://stackoverflow.com/a/44623098/4451521">this answer</a> I am trying to join two (actually more) images but I can not seem to make it right.
  Since images are difficult to comprehend (for me) I made a simple example</p>
  <pre><code>import numpy as np
  import cv2
  
  layer1 = np.zeros((5, 5, 4))
  layer2 = np.zeros((5,5,4))
  
  green_color = (0, 66, 0, 0)
  otro_color = (40,0,0,0)
  
  cv2.rectangle(layer1, (1, 1), (3, 3), green_color, 1)
  print(layer1)
  
  cv2.line(layer2, (1, 1), (3, 3), otro_color, 1)
  print(layer2)
  
  
  res = layer1[:]
  cnd = layer2[:, :, 0] &gt; 0  
  res[cnd] = layer2[cnd]  #&lt;-- this is not working correctly
  
  print(res)
  </code></pre>
  <p>As a result first I have a matrix</p>
  <pre><code>[[[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]]
  </code></pre>
  <p>Then I have the matrix</p>
  <pre><code>[[[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [ 40.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [ 40.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [ 40.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]]
  </code></pre>
  <p>as expected. However when trying to fuse it I have</p>
  <pre><code>[[[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [ 40.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [ 40.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [ 40.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]]
  </code></pre>
  <p>Which is not what I want. You can notice that in the second element everytime I apply 40 in the first channel, the 60 of the second channel dissappears.</p>
  <p>What I want to get is</p>
  <pre><code>[[[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [ 40.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [ 40.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.  66.   0.   0.]
    [  0.  66.   0.   0.]
    [ 40.  66.   0.   0.]
    [  0.   0.   0.   0.]]
  
   [[  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]
    [  0.   0.   0.   0.]]]
  </code></pre>
  <p>I've tried (without success) to do</p>
  <pre><code>res= layer1 | layer2  # does not work
  </code></pre>
  <p>also</p>
  <pre><code>cnd = np.logical_or(layer1,layer2)
  </code></pre>
  <p>which gives a nice mask of trues where I want to put values but then</p>
  <pre><code>res[cnd] = layer2[cnd]
  </code></pre>
  <p>ruins everything.</p>
  <p>How can I fusion those arrays to get the desired result?</p>