opencv 与操作 bitwise_and

效果图:
opencv 与操作  bitwise_and

#include"opencv2/highgui/highgui.hpp"
#include"opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;

int main()
{
    Mat img = imread("/data_2/python_c++_tools/python/dog.jpeg");
    Mat mask(img.rows,img.cols,CV_8UC3,Scalar(0,0,0));

    Rect r(882,397,714,539);//    Rect r(mask.cols*0.25,mask.rows*0.4,400,100);
    rectangle(mask,r,Scalar(255,255,255),-1);

    Mat m_out;
    bitwise_and(img,mask,m_out);

    namedWindow("img",0);
    namedWindow("m_out",0);
    namedWindow("mask",0);
    imshow("img",img);
    imshow("m_out",m_out);
    imshow("mask",mask);
    waitKey(0);
}
上一篇:opencv python图像梯度实例详解


下一篇:opencv+pytesseract 验证码识别!草鸡简单!