Merging two images showing brightness

后端 未结 1 1202
春和景丽
春和景丽 2021-01-25 06:35

I am trying to blend two image or you can say put one image on other image , when i apply blending overlay on the image or simple merge two image it show me brightness in it.

相关标签:
1条回答
  • 2021-01-25 07:22

    it's me again :) It seems you are writing new photoshop.

    The result I've got: enter image description here

    The code:

    #include <iostream>
    #include <vector>
    #include <stdio.h>
    #include <functional>
    #include <algorithm>
    #include <numeric>
    #include <cstddef>
    #include "opencv2/opencv.hpp"
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    using namespace cv;
     int main( int argc, char** argv )
    {
        namedWindow("Image");
    
        Mat Img1=imread("Img1.png",-1);
        Mat Img2=imread("Img2.png");
        cv::resize(Img1,Img1,Img2.size());
        Img1.convertTo(Img1,CV_32FC4,1.0/255.0);
        Img2.convertTo(Img2,CV_32FC3,1.0/255.0);
    
        vector<Mat> ch; 
        split(Img1,ch);
    
        Mat mask = ch[3].clone();              // here's the vignette
    
        ch.resize(3);
    
        Mat I1,I2,result;
    
        cv::multiply(mask,ch[0],ch[0]);
        cv::multiply(mask,ch[1],ch[1]);
        cv::multiply(mask,ch[2],ch[2]);
        merge(ch,I1);
    
        vector<Mat> ch2(3);
        split(Img2,ch2);
        cv::multiply(1.0-mask,ch2[0],ch2[0]);
        cv::multiply(1.0-mask,ch2[1],ch2[1]);
        cv::multiply(1.0-mask,ch2[2],ch2[2]);
        merge(ch2,I2);
    
        result=I1+I2;
    
        imshow("Image",result);
        waitKey(0);
    }
    
    0 讨论(0)
提交回复
热议问题