opencv学习实例代码3.2.2 两图像间的像素操作 2.两幅图像的逻辑运算

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html

#include <opencv2/objdetect.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <iomanip>
#include <opencv2/opencv.hpp>
#include <vector>
using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    Mat img=imread("lena.png");
    if(img.empty())
    {
        cout<<"open fail"<<std::endl;
    }
    Mat img0=Mat::zeros(200,200,CV_8UC1);
    Mat img1=Mat::zeros(200,200,CV_8UC1);
    Rect rect0(50,50,100,100);

    img0(rect0)=Scalar(255);
    Rect rect1(100,100,100,100);
    img1(rect1)=Scalar(255);
    imshow("img0",img0);
    imshow("img1",img1);
    
    Mat myAdd,myOr,myXor,myNot,imgNot;
    bitwise_not(img0,myNot);
    bitwise_and(img0,img1,myAdd);
    bitwise_or(img0,img1,myOr);
    bitwise_xor(img0,img1,myXor);
    bitwise_not(img,imgNot);
    imshow("myAdd",myAdd);
    imshow("myOr",myOr);
    imshow("myXor",myXor);
    imshow("myNot",myNot);
    imshow("imgNot",imgNot);
    string   sss;
    cin>>sss;
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值