合并两个显示亮度的图像 [英] Merging two images showing brightness

查看:990
本文介绍了合并两个显示亮度的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想混合两个图像,或者你可以说在其他图像上放置一个图像,当我应用混合覆盖图像或简单的合并两个图像,它显示在它的亮度。



这里是我的两个图像(第一个vignette从里面是空的,它不包含中心的亮度)





,另一个是





我所做的代码是

  int main(int argc,char ** argv)
{
Mat img = imread(E:\\vig.png, - 1);
Mat ch [4];
split(img,ch);
Mat im2 = ch [3]; //这里是小插曲
im2 = 255 - im2; // finally cure the inversion
Mat img2 = imread(E:\\ew.jpg);
Mat out2;
blending_overlay3(img2,im2,out2);
imshow(image,out2);
imwrite(E:\\image.jpg,out2);
waitKey();}


$ b



但我需要类似

的结果



EDIT



图像是中空/空的从中心(小插图一),但是当我用我的程序读取图像(小插图一),然后它变得实心(明亮)从中心,其实现的历史在这里



有唯一的问题,它与第一(小插图)图像读取,如果它读取,就像中空/空的中心,使我们合并/混合/重量的其他图像适用它不影响图像的中心部分,甚至不显示亮度等,这是我想做的

解决方案



我得到的结果:



代码:

  #include< iostream> 
#include< vector>
#include< stdio.h>
#include< functional>
#include< algorithm>
#include< numeric>
#include< cstddef>
#includeopencv2 / 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(); //这里是小插曲

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);
}


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.

here are my two images (first vignette is empty from inside , its not containing brightness in the centre )

and the other is

The code which i did is

int main( int argc, char** argv )
{
    Mat img=imread("E:\\vig.png",-1); 
    Mat ch[4]; 
    split(img,ch);
    Mat im2 = ch[3];              // here's the vignette
    im2 = 255 - im2; // eventually cure the inversion
    Mat img2 = imread("E:\\ew.jpg");
    Mat out2;
    blending_overlay3(img2 , im2 , out2);
    imshow("image",out2);
    imwrite("E:\\image.jpg",out2);
    waitKey();}

It show me the result like

but i require result like

EDIT

The first image is hollow/empty from center (the vignette one) , but when i read the image (vignette one) with my program then it become solid(bright) from the center , the history behind its implementation is here

There is the only problem and its with first (vignette) image reading , if it read as it is , like hollow/empty from the center , so that the other image with which we merge/blend/weight whatever apply it didn't effect the center part of the image , not even show brightness etc , that's what i want to do

解决方案

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

The result I've got:

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);
}

这篇关于合并两个显示亮度的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆