使用liner、feather、multiband对已经拼接的数据进行融合(下)
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
using namespace cv;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define DllExport _declspec (dllexport)
/*
1.设计一个mask(一半全1,一半全0),并计算level层的gaussion_mask[i];
2.计算两幅图像每一层的Laplacian[i],并与gaussion_mask[i]相乘,合成一幅result_lapacian[i];
3.对两幅图像不断求prydown,并把最高层保存在gaussion[i],与gaussion_mask[i]相乘,合成一幅result_gaussion;
4,对result_gaussion不断求pryup,每一层都与result_lapacian[i]合成,最后得到原-图像大小的融合图像。
*/
class LaplacianBlending {
private:
Mat_<Vec3f> top;
Mat_<Vec3f> down;
Mat_<);
maskGaussianPyramid.clear();
Mat currentImg;
//blendMask就是掩码
cvtColor(blendMask, currentImg, CV_GRAY2BGR); //store color img of blend mask into maskGaussianPyramid
maskGaussianPyramid.push_back(currentImg); //0-level
currentImg = blendMask;
for (int l=1; l<levels+1; l++) {
Mat _down;
if (topLapPyr.size() > l)
pyrDown(currentImg, _down, topLapPyr[l].size());
else
pyrDown(currentImg, _down, topHighestLevel.size()); //lowest level
Mat down;
cvtColor(_down, down, CV_GRAY2BGR);
maskGaussianPyramid.push_back(down); //add color blend mask into mask Pyramid
currentImg = _down;
}
}
//创建laplacian金字塔
void buildLaplacianPyramid(const Mat& img, vector<Mat_<Vec3f>; l<levels; l++) {
Mat down,up;
pyrDown(currentImg, down);
pyrUp(down, up,currentImg.size());
Mat lap = currentImg - up; //存储的就是残D差
lapPyr.push_back(lap);
currentImg = down;
}
currentImg.copyTo(HighestLevel);
}
Mat_<Vec3f> reconstructImgFromLapPyramid() {
//将左右laplacian图像拼成的resultLapPyr金字塔中每一层
//从上到下插值放大并相加,即得blend图像结果
Mat currentImg = resultHighestLevel;
for (int l=levels-1; l>=0; l--) {
Mat up;
pyrUp(currentImg, up, resultLapPyr[l].size());
currentImg = up + resultLapPyr[l];
}
return currentImg;
}
void blendLapPyrs() {
//获得每层金字塔中直接用左右两图Laplacian变换拼成的图像
//一半的一半就是在这个地方计算的。 是基于掩模的方式进行的.
resultHighestLevel = topHighestLevel.mul(maskGaussianPyramid.back()) +
downHighestLevel.mul(Scalar(1.0,1.0,1.0) - maskGaussianPyramid.back());
for (int l=0; l<levels; l++) {
Mat A = topLapPyr[l].mul(maskGaussianPyramid[l]);
Mat antiMask = Scalar(1.0,1.0,1.0) - maskGaussianPyramid[l];
Mat B = downLapPyr[l].mul(antiMask);
Mat_<Vec3f> blendedLevel = A + B;
resultLapPyr.push_back(blendedLevel);
}
}
public:
LaplacianBlending( const Mat_<Vec3f>& _top, const Mat_<Vec3f>& _down, const Mat_<);
return lb.blend();
}
DllExport double aValue =1.5;
DllExport int dlladd()
{
return;
}
DllExport int dlladd( int a,int b)
{
return a+b;
}
DllExport cv::Mat imagetest()
{
cv::Mat image1= cv::imread( "C:\\apple.png",1);
cv::Mat image2= cv::imread( "C:\\orange.png",1);
Mat_<Vec3f> t; image1.convertTo(t,CV_32F,1.0/255.0); //Vec3f表示有三个通道,即 [row][column][depth]
Mat_<Vec3f> d; image2.convertTo(d,CV_32F,1.0/255.0);
Mat_<.0); //将m全部赋3值为a0
//m(Range::all(),Range(0,m.cols/2)) = 1.0; //原来初始的掩码是在这里
m(Range(0,m.rows/2),Range::all())=1.0;
Mat_<Vec3f> blend = LaplacianBlend(t,d, m);
imshow( "blended",blend);
return blend;
}
;

使用liner、feather、multiband对已经拼接的数据进行融合(下)的更多相关文章
- 使用liner、feather、multiband对已经拼接的数据进行融合
所谓"blend",英文解释为“vt. 混合vi. 混合:协调n. 混合:掺合物”这里应该理解为是图像数据的融合.这是“识别->对准->融合”的最后一步.融合是决定拼接 ...
- 关于json动态拼接响应数据
在EasyUI http://www.jeasyui.com/demo/main/get_users.php 响应数据如下格式: { "total": "11" ...
- 使用concat做字符串拼接和数据迁移
作用: 解决一开始数据库建立不合理造成的字段冗余,从而提取部分字段,数据迁移.拼接字符串的功能. 格式: concat(字段1,'间隔符',字段2....) concat_ws('间隔符',字段1,字 ...
- Python接口测试-以&连接拼接字典数据(get中url请求数据)
get请求的utl数据是这样的,例如:/banner/findBanner?bannerType=1&_=1556107073181 ''' 1-banner图-banner/findBann ...
- python 手动拼接json数据
第一步:分别拼接为字符串 第二步:将字符串转化为list 第三歩:将两个list合并为dict 第四步:将dict转换为接送数据 如: import json keys = ['a', 'b', ' ...
- udp拼接传递数据包
1.拼接项少 pl = ["<0112>","<32>","<1024x768>","< ...
- sql server full join拼接表数据,按组加序号
--查询所有数据select A.*,B.* from(select z.id,z.requestId,z.FBillNo,dt5.FCauseAndProcess,dt5.FEquipmentNo, ...
- SQL拼接字段数据
查询语句: SELECT STUFF ( ( SELECT ',' + --分隔符 KeyID --查询字段 FROM #tmp --查询数据表 WITH(NOLOCK) --查询条件 FOR XML ...
- C#拼接SQL语句,SQL Server 2005+,多行多列大数据量情况下,使用ROW_NUMBER实现的高效分页排序
/// <summary>/// 单表(视图)获取分页SQL语句/// </summary>/// <param name="tableName"&g ...
随机推荐
- unity3d对象池的使用
说对象池之前首先来看看单例类和单例脚本的区别.这里有介绍 http://blog.csdn.net/lzhq1982/article/details/12649281 使用对象池的好处是不用每次都创建 ...
- jQuery-切换效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- nginx空白图片(empty_gif模块)
用过百度统计的兄弟有没有注意到百度使用1x1的空白图片传递统计参数,自己做异步统计的兄弟是否使用静态文件来传递参数.为什么使用空白图片呢,而不是自己存放一张小图呢,nginx里面的空白图片是保存在内存 ...
- JS实例3
window.setInterval("Time()",1); function Time() { var date = new Date();//当前时间函数 var n = d ...
- 将网站项目转为 Web form应用程序(转)
转自 http://blog.sina.com.cn/s/blog_53729e4601014ze9.html 本文介绍如何将现有的 Microsoft Visual Studio 2005 网站项目 ...
- linux常用系统工作命令
1.echo命令 echo命令用于在终端输出字符串或变量提取后的值,格式为“echo [字符串 | $变量]”. 2.date命令 date命令用于显示及设置系统的时间或日期,格式为“date [选项 ...
- linux下安装mysql等信息
1.安装 apt-get update;// 第一次的时候,你更新一下你的软件包的源地址数据; apt-get install mysql-server 2.账号登陆 mysql -h localho ...
- 20155228 2016-2017-2 《Java程序设计》第1周学习总结
20155228 2016-2017-2 <Java程序设计>第1周学习总结 教材学习内容总结 这部分内容是以教材为基础,根据个人的理解来描述的,有的地方的理解和表述可能不规范甚至不正确, ...
- 凯撒密码、GDP格式化输出、99乘法表
1.恺撒密码的编码 s=input('明文:') print('密文:',end='') for i in s: print(chr(ord(i)+3),end='') 附加: print('字符串的 ...
- python glob 模块
glob模块用来查找文件目录和文件,可以和常用的find功能进行类比.glob支持*?[]这三种通配符.返回的数据类型是list.常见的两个方法有glob.glob()和glob.iglob(),ig ...