title: Why Image masking with opencv returns "Sizes of input arguments do not match"?
body: <p>I am trying to mask two image with each other. The first one is a regular RGB image and the second one is one channel binary image.</p>
  
  <p>I stacked the binary image so it will be 3 channel like the first image and then used bitwise_and. I still get the error </p>
  
  <blockquote>
    <p>(-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and type), nor 'array op scalar', nor 'scalar op array' in function 'cv::binary_op'</p>
  </blockquote>
  
  <pre><code>im = cv2.imread(image_name) # shape : (1280, 960, 3)
  
  h, w = im.shape[:2]
  
  mask = predict[0] #output of some network with shape of (256, 256, 1) and type of numpy.ndarray
  
  
  mask = cv2.resize(mask, (w, h)) # resizing mask to the same shape if input
  
  mask = np.stack((mask,)*3, axis=-1) # make it 3 channel, shape : (1280, 960, 3)
  
  output = cv2.bitwise_and(im, mask)
  </code></pre>
  
  <p>I examined the shape of the mask and input right before computing output and they were they same size and type. Does anyone know where the problem is?</p>