使用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 ...
随机推荐
- iOS UI布局-回到顶部
回到顶部,是比较常用的一个效果 核心代码 在ViewDidLoad中,添加回到顶部按钮 计算偏移量,如果当前显示的内容全部向上隐藏掉,则显示“回到顶部”按钮 // // ViewController. ...
- iOS UI进阶-4.0 地图与定位
在移动互联网时代,移动app能解决用户的很多生活琐事,比如 导航:去任意陌生的地方 周边:找餐馆.找酒店.找银行.找电影院 在上述应用中,都用到了地图和定位功能,在iOS开发中,要想加入这2大功能 ...
- iOSOpenDev安装使用
下载:http://iosopendev.com/download/ 选择“iOSOpenDev 1.6-2 Installer” 出错解决方法 https://www.jianshu.com/p/2 ...
- Servlet交互与JSP
主要内容介绍 数据共享与页面跳转 1. 为什么要有跳转: Servlet需要跳转到其它Servlet中,因为我们需要职责分明,不同Servlet来完成不同的功能 Servlet跳转到JSP中,Serv ...
- Oracle 10g使用amdu抽取数据文件
环境:OEL 5.7 + Oracle 10.2.0.5 RAC 需求:实验在Oracle 10g环境使用amdu抽取数据库文件 本文主要目的是介绍3个知识点: 1.使amdu可以在oracle 10 ...
- oracle 常用(二)
多表查询: 1.等值连接查询: select a.aa,a.bb,b.qq from XX a , CC b where a.aa= b.ee 2.不等值连接: select * fr ...
- SqlServer表和EXCEL数据互相复制方法
一.SqlServer表数据复制到excel 1.新建查询,用sql语句把表数据读出来 2.然后,选择数据,右键,复制(也可以点击连同标题复制),复制到记事本中(不然会乱码) 3.然后再把记事本的内容 ...
- TP父类及模板继承
一.TP父类方法继承 session用法 用登录页面做例子 <?php namespace Home\Controller; use Think\Controller; class LoginC ...
- python中的list的*运算使用过程中遇到的问题
目的: 想生成一个[[],[],[]] 这样的列表, 所以就 [[]]*3 这样做了,但是这样做会有问题,这样list中的三个list其实是同一个list. 例如:a=[[]]*3,然后a[0].ap ...
- TensorFlow的封装
TensorFlow是比较底层的深度学习API,TF-Slim.TFLearn.Keras和TensorLayer均尝试简化TensorFlow/Theano,它们对TensorFlow/Theano ...