title: cvSetImageROI using greyscale and color images
body: <p>I'm trying to set an image region of interest and add one image into another. One image is a mask (greyscale) and the other one is a color image. Right now, I'm doing</p>
  
  <pre><code>IplImage * _newImg = newImage.getCvImage();
  IplImage * _oldBG  = tempBG.getCvImage();
  
  CvRect rect = cvRect(100, 100, _newImg-&gt;width, _newImg-&gt;height);
  
  cvSetImageROI(_oldBG, rect);
  cvAdd(_newImg, _oldBG, _newImg, NULL);
  
  cvResetImageROI(_oldBG);
  </code></pre>
  
  <p>This causes the following error:</p>
  
  <blockquote>
    <p>OpenCV Error: Assertion failed (src1.size() == src2.size()) in
    binaryMaskOp,</p>
  </blockquote>
  
  <p>I've stepped through the code, and both images are the same size. I'm assuming the problem is that one image is color and the other is greyscale. Is there a way to perform the procedure above using images with different channels?</p>
  
  <p>Thanks.</p>