title: Numpy compare two 3d array and find identical arrays
body: <p>I have 2 arrays, </p>
  
  <pre><code>mat = np.array(
      [
          [[0,0],[0,1],[0,2]],
          [[1,0],[1,1],[1,2]],
          [[2,0],[2,1],[2,2]]
      ]
  )
  mat2 = np.array(
      [
          [[0,1],[0,1],[0,2]],
          [[1,0],[1,1],[1,2]],
          [[2,0],[2,2],[2,2]]
      ]
  )
  </code></pre>
  
  <p>I would like to find all the arrays in axis 2 which are the same in both <code>mat</code> and <code>mat2</code> and turn them into an array of zeros. Differently speaking, if each array <code>mat</code> and <code>mat2</code> was a RGB image, I would like to find the pixels with the same R,G,B values and return an image with the same pixels set as (0,0,0) and the rest of the pixels intact.</p>
  
  <p>So the output I'm trying to achieve with the above arrays would be this:</p>
  
  <pre><code>[
      [[0, 1], [0, 0], [0, 0]],
      [[0, 0], [0, 0], [0, 0]],
      [[0, 0], [2, 2], [0, 0]]
  ]
  </code></pre>
  
  <p>I have tried the following code:</p>
  
  <pre><code>operated = np.where((mat2-mat==0).all(axis=2), np.array([0,0]), mat2)
  </code></pre>
  
  <p>However it would say:</p>
  
  <pre><code>ValueError: operands could not be broadcast together with shapes (3,3) (2,) (3,3,2) 
  </code></pre>
  
  <p>I think it's because it returns just one <code>True</code> or <code>False</code> for each array in axis 2 which instead should be <code>(True , True)</code> if pixel is same, or <code>(False, False)</code> if subtraction should not be done.</p>