[wiki,blog]使用opencv自带的融合函数

[wiki,blog]使用opencv自带的融合函数

/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                        Intel License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of Intel Corporation may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "stdafx.h"
#include "test_precomp.hpp"
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
 
using namespace cv;
using namespace std;
 
int main()
{
    Mat image1 = imread( "c:\\3.jpg");
    Mat image2 = imread( "c:\\4.jpg");
    ASSERT_EQ(image1.rows, image2.rows); ASSERT_EQ(image1.cols, image2.cols);
 
    Mat image1s, image2s;
    image1.convertTo(image1s, CV_16S);
    image2.convertTo(image2s, CV_16S);
 
    Mat mask1(image1s.size(), CV_8U);
   /* mask1(Rect(0, 0, mask1.cols/2, mask1.rows)).setTo(255);
    mask1(Rect(mask1.cols/2, 0, mask1.cols - mask1.cols/2, mask1.rows)).setTo(0);*/
                mask1(Rect(0,0, mask1.cols , mask1.rows)).setTo(0);
                mask1(Rect(0, 0, mask1.cols, mask1.rows/2)).setTo(255);
                
 
    Mat mask2(image2s.size(), CV_8U);
   /* mask2(Rect(0, 0, mask2.cols/2, mask2.rows)).setTo(0);
    mask2(Rect(mask2.cols/2, 0, mask2.cols - mask2.cols/2, mask2.rows)).setTo(255);*/
                mask2(Rect(0,0, mask2.cols , mask2.rows)).setTo(255);
                mask2(Rect(0, 0, mask2.cols, mask2.rows/2)).setTo(0);
 
 
    detail::MultiBandBlender blender( false, 5);
 
    blender.prepare(Rect(0, 0, max(image1s.cols, image2s.cols), max(image1s.rows, image2s.rows)));
    blender.feed(image1s, mask1, Point(0,0));
    blender.feed(image2s, mask2, Point(0,0));
 
    Mat result_s, result_mask;
    blender.blend(result_s, result_mask);
    Mat result; result_s.convertTo(result, CV_8U);
 
                cv::imshow( "result",result);
                cv::imwrite( "baboon_lena.jpg",result);
                cv::waitKey();
 
}
实现了速度很快,效果很好的mulitband的结果,但是对于实际的项目也是有不足的,就是只能输入两幅图像。如果需要用于实际的项目,就需要进行修正,使得其能够一下子用于许多图像。
  

使用opencv自带的融合函数的更多相关文章

  1. cvSmooth函数 和 OpenCV自带的人脸检测

    记录cvSmooth函数的用法和 OpenCV自带的人脸检测. (1)cvSmooth函数 void cvSmooth( const CvArr* src, CvArr* dst,int smooth ...

  2. opencv通过dll调用matlab函数,图片作为参数

    [blog 项目实战派]opencv通过dll调用matlab函数,图片作为参数                   前文介绍了如何“csharp通过dll调用opencv函数,图片作为参数”.而在实 ...

  3. 如何利用OpenCV自带的级联分类器训练程序训练分类器

    介绍 使用级联分类器工作包括两个阶段:训练和检测. 检测部分在OpenCVobjdetect 模块的文档中有介绍,在那个文档中给出了一些级联分类器的基本介绍.当前的指南描述了如何训练分类器:准备训练数 ...

  4. 利用opencv自带源码,调试摄像头做人脸检测

    本文为原创作品,转载请注明出处 欢迎关注我的博客:http://blog.csdn.net/hit2015spring 和 http://www.cnblogs.com/xujianqing/ 作者: ...

  5. 基于Opencv自带BP网络的车标简易识别

    代码地址如下:http://www.demodashi.com/demo/12966.html 记得把这几点描述好咯:代码实现过程 + 项目文件结构截图 + 演示效果 1.准备工作 1.1 训练集和测 ...

  6. JS中setInterval、setTimeout不能传递带参数的函数的解决方案

    在JS中无论是setTimeout还是setInterval,在使用函数名作为调用句柄时都不能带参数,而在许多场合必须要带参数,接下来为大家介绍具体的解决方法 在JS中无论是setTimeout还是s ...

  7. 在Windows下利用php自带的mail函数发邮件

    这几天看<Head First PHP & MySQL>,里面有发邮件的例子是用系统自带的mail函数发送的,自己照书上写的试了一直不成功,后来终于在网上找到解决方案,现在总结下. ...

  8. 关于C#中函数声明带参数的函数

    在C#语言的函数中,有一项至关重要的我们称之为参数. 对于参数的含义:要完成一件事,需要知道的额外条件 其语法: static void 函数名(参数列表){ //注释类容} 而其参数列表的语法为: ...

  9. OpenCV 学习笔记03 findContours函数

    opencv-python   4.0.1 1 函数释义 词义:发现轮廓! 从二进制图像中查找轮廓(Finds contours in a binary image):轮廓是形状分析和物体检测和识别的 ...

随机推荐

  1. Leetcode: Rotate Function

    Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotati ...

  2. Sublime 不自动打开上次未关闭的文件 设置方法

    { "font_size": 17, "hot_exit": false, "remember_open_files": false, &q ...

  3. angular 和jq 的AJAX的请求区别

    最近项目中使用angular,结果发现后台没法获取参数,所以,稍微研究了一下两者在发送ajax时的区别. 注意angular和jquery的ajax请求是不同的. 在jquery中,官方文档解释con ...

  4. 利用MyEclipes的反转工程来配置Hibernate各种配置

    首先需要有设计好的数据库,然后创建一个Web Project然后右键点击项目选择MyEclipse→add Hibernate Capabilities →→ →→,然后如果没有管理员的话需要在选择M ...

  5. bzoj3437 小P的牧场

    斜率优化dp 代码 #include<cstdio> #include<algorithm> using namespace std; typedef long long ll ...

  6. redis数据库使用测试

    注:java spring data redis内置了几种redis序列化机制.JdkSerializationRedisSerializer最高效.有关序列化更详细的介绍-http://www.my ...

  7. 夺命雷公狗ThinkPHP项目之----企业网站16之文章列表页的完善(关联查询)

    我们栏目的所属栏目不能总是以数字来显示吧??这样的话,估计老板会让您直接卷铺盖滚蛋噢,嘻嘻... 所以我们需要对她进行关联查询,控制器代码如下所示: public function lists(){ ...

  8. 赤手空拳编写C#代码

    有时候服务器上并没有安装任何IDE或典型的代码编辑器,只能完全手写C#代码. 不妨假设一台全新的PC,较新版本的Windows自带了.net框架,无需开发工具即可编程了. 除了以往的Bat批处理.VB ...

  9. expandlistview

    package com.exaple.zhonghe2; import java.sql.SQLData;import java.util.ArrayList;import java.util.Has ...

  10. 统一使用GPT分区表,安装MAC 10.10 和 Win8.1 pro双系统

    步骤一: 为Mac OS 分区,为其它分区留白1,使用OSX Mavericks制作的Mac安装U盘按住Option键启动:2,选择安装Mavericks盘符:3,进入OSX安装启动界面,选择磁盘工具 ...