其他分享
首页 > 其他分享> > 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);
}

标签:Mat,img,imshow,mask,bitwise,opencv,操作,255,out
来源: https://www.cnblogs.com/yanghailin/p/12175088.html