理解mulitband。所谓的mulitband,其实就是一种多尺度的样条融合,其实现的主要方法就是laplace金字塔。

高斯金字塔是向下采样,而laplace金字塔式向上采样(也就是恢复),采用的都是差值的方法。如何能够在金字塔各个层次上面进行图像的融合,结果证明是相当不错的。网络上面流传的一个类解释了这个问题,并且能够拿来用:
// GOImage.cpp : 定义? DLL 的?初?始?化例y程。
//
 
#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_< float> blendMask; 
 
                vector<Mat_<Vec3f> > topLapPyr,downLapPyr,resultLapPyr; //Laplacian Pyramids  
                Mat topHighestLevel, downHighestLevel, resultHighestLevel; 
                vector<Mat_<Vec3f> > maskGaussianPyramid; //masks are 3-channels for easier multiplication with RGB  
 
                 int levels; 
 
                 //创建金e字?塔t
                 void buildPyramids() { 
                                 //参?数y的?解a释 top就是?top ,topLapPyr就是?top的?laplacian的?pyr,而?topHighestLevel保存?的?是?最?高?端?的?高?斯1金e字?塔t
                                buildLaplacianPyramid(top,topLapPyr,topHighestLevel);  
                                buildLaplacianPyramid(down,downLapPyr,downHighestLevel); 
                                buildGaussianPyramid(); 
                } 
 
                 //创建gauss金e字?塔t
                 void buildGaussianPyramid() {//金e字?塔t内容Y为a每?一?层?的?掩模  
                                assert(topLapPyr.size()>0); 
 
                                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金e字?塔t
                 void buildLaplacianPyramid(const Mat& img, vector<Mat_<Vec3f> >& lapPyr, Mat& HighestLevel) { 
                                lapPyr.clear(); 
                                Mat currentImg = img; 
                                 for (int l=0; 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金e字?塔t中D每?一?层?  
                                 //从上?到?下?插?值放?大并相加,?即得?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() { 
                                 //获?得?每?层?金e字?塔t中D直接用?左右两?图?Laplacian变?换?拼成的?图?像?resultLapPyr  
                                 //一?半?的?一?半?就是?在这a个?地?方?计?算?的?。 是?基于掩模的?方?式?进?行D的?.
                                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_< float>& _blendMask, int _levels)://缺省?数y据Y,?使1用? LaplacianBlending lb(l,r,m,4);  
                  top(_top),down(_down),blendMask(_blendMask),levels(_levels) 
                  { 
                                  assert(_top.size() == _down.size()); 
                                  assert(_top.size() == _blendMask.size()); 
                                  buildPyramids();  //创建laplacian金e字?塔t和gauss金e字?塔t
                                  blendLapPyrs();   //将?左右金e字?塔t融合?成为a一?个?图?片?  
                  }; 
 
                  Mat_<Vec3f> blend() { 
                                  return reconstructImgFromLapPyramid();//reconstruct Image from Laplacian Pyramid  
                  } 
}; 
 
Mat_<Vec3f> LaplacianBlend( const Mat_<Vec3f>& t, const Mat_<Vec3f>& d, const Mat_< float>& m) { 
                LaplacianBlending lb(t,d,m,4); 
                 return lb.blend(); 
 
 
DllExport double aValue =1.5;
DllExport int dlladd()
{
                 return 5;
}
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表示?有D三y个?通道,?即 l[row][column][depth]  
                Mat_<Vec3f> d; image2.convertTo(d,CV_32F,1.0/255.0); 
 
                Mat_< float> m(t.rows,d.cols,0.0);                 //将?m全?部?赋3值为a0  
                 //m(Range::all(),Range(0,m.cols/2)) = 1.0;    //原-来初?始?的?掩码?是?在这a里?!?!?
                m(Range(0,m.rows/2),Range::all())=1.0;
                Mat_<Vec3f> blend = LaplacianBlend(t,d, m); 
 
                imshow( "blended",blend); 
                 return blend;
}
需要注意的是, m(Range(0,m.rows/2),Range::all())=1.0表明了原始图像的掩码,这个掩码就是那个分界的地方

转载于:https://www.cnblogs.com/jsxyhelu/p/3847382.html

使用liner、feather、multiband对已经拼接的数据进行融合(下)相关推荐

  1. Pandas简明教程:九、表的合并、连接、拼接(数据聚合基础)

    真实场景中常会遇到多种信息放在不同的表里的情况,此时我们就需要将这些表格的信息整合到一起.这种操作可以极大地减轻我们手动粘数据的工作,从而达到事半功倍的效果. 由于本篇要举的例子较多,因此直接采用官网 ...

  2. mysql 新增拼接_mysql insert into新增group_concat查询出来拼接的数据

    mysql insert into新增group_concat查询出来拼接的数据如何实现? 代码如下: INSERT INTO yt_keywords ( id, post_keywords ) SE ...

  3. 数据库语句常见方法:(随机生成Id,结合CSAE...WHEN的使用,分组拼接字段数据

    随机生成ID/UUID 1.获取IDSELECT newid() 2.将UUID值中的-替换SELECT REPLACE( newid(), '-', '' ) 3.获取ID并转小写SELECT LO ...

  4. python 手动拼接json数据

    第一步:分别拼接为字符串 第二步:将字符串转化为list 第三歩:将两个list合并为dict 第四步:将dict转换为接送数据 如: import json keys = ['a', 'b', 'c ...

  5. python数据框拼接_pandas数据拼接的实现示例

    一 前言 pandas数据拼接有可能会用到,比如出现重复数据,需要合并两份数据的交集,并集就是个不错的选择,知识追寻者本着技多不压身的态度蛮学习了一下下: 二 数据拼接 在进行学习数据转换之前,先学习 ...

  6. 6000字 “保姆级” 教程 | 讲述Pandas库的数据读取、数据获取、数据拼接、数据写出!

    1. pandas介绍 Pandas是一个强大的数据分析库,它的Series和DataFrame数据结构,使得处理起二维表格数据变得非常简单. 基于后面需要对Excel表格数据进行处理,有时候使用Pa ...

  7. 使用FULL OUTER JOIN拼接表数据

    今天帮用户修改一个报表,里边设计到出库和入库的操作,要将每个产品每天的出入口信息列出来. 可能存在这样的情况: 1.   产品在出库表中存在数据但是入库表中没有数据 2.   产品入库表中存在数据但是 ...

  8. 多帧点云数据拼接合并_自动驾驶:Lidar 3D传感器点云数据和2D图像数据的融合标注...

    自动驾驶汽车的发展已经见证了硬件传感器记录感官数据的容量和准确度的发展.传感器的数量增加了,新一代传感器正在记录更高的分辨率和更准确的测量结果. 在本文中,我们将探讨传感器融合如何在涉及环环相扣的数据 ...

  9. html页面拼接,表格数据

    controler层: @RequestMapping("/a2")public List<User> a2(){LinkedList<User> list ...

最新文章

  1. 梁胜:做云计算,如何才能超越AWS?
  2. 一起来造一个RxJava,揭秘RxJava的实现原理
  3. 记录 之 tf.data进行数据集处理常用的几个函数介绍
  4. first review of team blog(4.26)
  5. ElasticSearch查询返回信息根据字段排序(英文检索)
  6. 微博发布公告 将开展财经违规内容专项整治行动
  7. mybatis ------ mybatis和spring整合(十一)
  8. Oracle结构组成
  9. rbw设计_华为5G最新突破!我国每周增加1万个5G基站!频谱分析仪中RBW和VBW的区别...
  10. java方法分为类方法和_— Must we finish copying all these articles this morning? — No, you( )._学小易找答案...
  11. 如何便捷的获取AD(Altium Designer)封装、以及如何从PCB工程中导出封装库、封装库安装
  12. linux环境编程apue和unp,UNIX高级环境编程:源码(apue)下载 编译和运行
  13. JVM(三)类加载与字节码技术
  14. 工作薄与工作表的区别:
  15. 华三路由交换配置命令_华三华为交换机-路由器配置常用命令汇总
  16. Matlab实现Taylor展开近似计算、五角星画法
  17. 人体工程学枕头行业调研报告 - 市场现状分析与发展前景预测
  18. html跳转到关注的微信公众号,手机浏览器一键跳转微信公众号关注的方法
  19. 微信小程序播放视频卡顿问题
  20. 基因家族TBTools

热门文章

  1. 程序员致富的若干方法探讨
  2. 项目总设计师应做好设计控制
  3. [转] linux IO
  4. POJ-1182 食物链(并查集)
  5. Socket拉屎模型之二--实践篇
  6. Windos 解决Flutter 报错
  7. 算法------数组---------存在重复元素
  8. Proguard returned with error code 1. See console
  9. 【剑指offer-Java版】30最小的K个数
  10. 我来告诉你【Redis】入门 一