zoukankan      html  css  js  c++  java
  • opencv学习笔记1 加载图像 图像融合 分通道与合并

    1.加载图像

    1 #include<opencv.hpp>
    2 using namespace cv;
    3 int main()
    4 {
    5     Mat a = imread("E:/test.jpg");
    6     imshow("picture", a);
    7     waitKey();
    8     return 0;
    9 }

    2.图像融合

     1 #include<opencv2/opencv.hpp>
     2 #include<opencv2/core/core.hpp>
     3 #include<opencv2/highgui/highgui.hpp>
     4 
     5 using namespace cv;
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     Mat background = imread("E:/test.jpg"); 
    11 
    12     Mat logo = imread("E:/logo.jpg");
    13 
    14     Mat imageROI=background(Rect(100, 100, logo.cols, logo.rows));  //在background上定义感性区域
    15 
    16     addWeighted(imageROI, 0.5, logo, 0.3, 0., imageROI); //融合,将logo融合到ROI上,保存为ROI
    17     
    18     waitKey();
    19     return 0;
    20 }

    3.分通道

     1 #include<iostream>
     2 #include<vector>
     3 #include<opencv2/opencv.hpp>
     4 using namespace std;
     5 using namespace cv;
     6 int main3()
     7 {
     8     Mat src = imread("E:/test.jpg");
     9     imshow("src", src);
    10     vector<Mat> channels;
    11     split(src, channels);
    12     
    13     Mat blue, green, red;
    14     blue = channels.at(0);
    15     green= channels.at(1);
    16     red= channels.at(2);
    17     imshow("blue", blue);
    18     imshow("green", green);
    19     imshow("red", red);
    20 
    21     waitKey();
    22     return 0;
    23 }

    合并

    1 Mat dst;
    2     merge(channels, dst);
    3     imshow("dst", dst);
  • 相关阅读:
    93. Restore IP Addresses
    mysql复制那点事(2)-binlog组提交源码分析和实现
    49. Group Anagrams
    43. Multiply Strings
    66. Plus One
    100. Same Tree
    MySQL 加锁处理分析
    mysql死锁问题分析
    数据库事务的四大特性以及事务的隔离级别
    MySQL常见的三种存储引擎(InnoDB、MyISAM、MEMORY)
  • 原文地址:https://www.cnblogs.com/sclu/p/11498188.html
Copyright © 2011-2022 走看看