Posted By

browny on 09/10/10


Tagged

mask opencv


Versions (?)

[OpenCV] Use a image to mask another image


 / Published in: C++
 

利用一張影像當做遮罩,只顯示來源影像的一部分!

  1. void showMaskPart(const IplImage* src, const IplImage* mask, IplImage* result)
  2. {
  3. /* src is the source image which you want to mask
  4.   * mask is a single channel binary image as a mask
  5.   * result is the image with the same size, depth, channel with src
  6.   */
  7.  
  8. cvZero(result);
  9.  
  10. CvSize sz = cvSize(src->width, src->height);
  11. IplImage* refImg = cvCreateImage(sz, src->depth, src->nChannels);
  12. cvZero(refImg);
  13.  
  14. cvOr(src, refImg, result, mask);
  15.  
  16. cvReleaseImage(&refImg);
  17.  
  18. }

Report this snippet  

You need to login to post a comment.