• OpenCV——ROI截取、线性混合、通道分离、合并、亮度对比度调整


     1 #include <opencv2/opencv.hpp>
     2 #include <iostream>
     3 
     4 using namespace cv;
     5 using namespace std;
     6 
     7 int main(int argc, char** argv)
     8 {
     9     Mat src = imread("test.jpg");
    10     Mat logo = imread("logo.jpg");
    11     
    12     //设定ROI区域
    13     Mat ROI = src(Rect(20, 25, logo.cols, logo.rows));//注意这边Rect函数,先列后行(长*高(宽))
    14     imshow("原始ROI", ROI);
    15 
    16     //用logo的图像矩阵替换掉ROI区域的数据
    17     logo.copyTo(ROI);
    18 
    19     imshow("后来ROI", ROI);
    20     imshow("src", src);
    21 
    22     waitKey(0);
    23     return 0;
    24 
    25 }

     1 #include <opencv2/opencv.hpp>
     2 #include <iostream>
     3 
     4 using namespace cv;
     5 using namespace std;
     6 
     7 int main(int argc, char** argv)
     8 {
     9     Mat src = imread("test.jpg");
    10     Mat logo = imread("logo.jpg");
    11     
    12     //设定ROI区域
    13     Mat ROI = src(Rect(20, 25, logo.cols, logo.rows));//注意这边Rect函数,先列后行(长*高(宽))
    14     imshow("ROI", ROI);    
    15 
    16     addWeighted(ROI,1, logo, 0.1, 0., ROI,-1);//两张图片必须大小相同
    17     imshow("src", src);
    18 
    19     waitKey(0);
    20     return 0;
    21 
    22 }

     1 #include <opencv2/opencv.hpp>
     2 #include <iostream>
     3 
     4 using namespace cv;
     5 using namespace std;
     6 
     7 int main(int argc, char** argv)
     8 {
     9     Mat src = imread("test.jpg");
    10     Mat ROI;
    11     vector<Mat> channls;
    12     split(src, channls);
    13     ROI = channls.at(0);
    14     
    15     imshow("ROI", ROI);    
    16     imshow("src", src);
    17 
    18     waitKey(0);
    19     return 0;
    20 
    21 }

     1 #include <opencv2/opencv.hpp>
     2 #include <iostream>
     3 
     4 using namespace cv;
     5 using namespace std;
     6 
     7 int main(int argc, char** argv)
     8 {
     9     Mat src = imread("test.jpg");
    10     Mat Red,Green,Blue,dst;
    11     vector<Mat> channls;
    12     split(src, channls);
    13     Blue = channls.at(0);
    14     Green = channls.at(0);
    15     Red = channls.at(0);
    16     
    17     imshow("Blue", Blue);
    18     imshow("Green", Green);
    19     imshow("Red", Red);
    20     imshow("src", src);
    21 
    22     merge(channls, dst);
    23     imshow("dst", dst);
    24 
    25     waitKey(0);
    26     return 0;
    27 
    28 }

  • 相关阅读:
    struts-OGNL
    Linux开发环境配置大全
    Mybartis逆向工程
    开发环境配置大全
    金三银四,你的专属复习宝典
    Java5~11新特性
    Struts2+Spring+Hibernate整合开发(Maven多模块搭建)
    三层架构,Struts2,SpringMVC实现原理图
    Springmvc+Spring+Mybatis整合开发(架构搭建)
    MyBatis面试题整理
  • 原文地址:https://www.cnblogs.com/long5683/p/9655910.html
Copyright © 2020-2023  润新知