title: operands could not be broadcast together with shapes (780,1080) (780,1080,3)
body: <p>I'm using opencv and numpy for image processing. </p>
  
  <p>I am thresholding an image and then doing some processing on it and later I mask it with the original image. </p>
  
  <p>I do threshold like this (step1):</p>
  
  <pre><code>    ret,thresh1 = cv2.threshold(gray,210,255,cv2.THRESH_TOZERO)
  </code></pre>
  
  <p>Then I assign <code>thresh1</code> to <code>img</code> (step2):</p>
  
  <pre><code>    img = thresh1
  </code></pre>
  
  <p>and I mask like this (step3):</p>
  
  <pre><code>    final = img&amp;cv2.cvtColor(less, cv2.COLOR_GRAY2BGR)
  </code></pre>
  
  <p>However, with this I get the following error on step3: </p>
  
  <pre><code>    operands could not be broadcast together with shapes (780,1080) (780,1080,3)
  </code></pre>
  
  <p>If I replace step2 with: </p>
  
  <pre><code>    cv2.imwrite("2.png", thresh1)
      img = cv2.imread("2.png")
  </code></pre>
  
  <p>Then everything works fine. I can't understand the difference in actually saving and then reading the same image from disk vs. just assigning <code>img</code> to <code>thresh1</code></p>
  
  <p>Is there a way I can avoid writing and reading the image from disk?</p>