[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. C++Primer 第五章

    //1.表达式语句的作用:执行表达式并丢弃求值结果 ; value + ; //执行,并丢弃结果 //2.复合语句是指用花括号括起来的语句和声明的序列,复合语句称为块.一个块就是一个作用域.块不以分号 ...

  2. 为benchmarksql的PostgreSQL java驱动进行升级

    为benchmarksql的PostgreSQL java驱动进行升级[root@minion1 benchmarksql-4.1.0]# wget https://jdbc.postgresql.o ...

  3. Leetcode: Range Sum Query 2D - Mutable && Summary: Binary Indexed Tree

    Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper lef ...

  4. Java中几种日志方案

    .本文记录Java中几种常用的日志解决方案 0x01 Log4j .这应该是一个比较老牌的日志方案了,配置也比较简单,步骤如下 1)添加对应依赖,比如 Gradle 中 dependencies { ...

  5. java系统时间的调用和格式转换

    java在java.text   java.util   java.lang包中查找 import java.util.*; import java.text.*; public class Text ...

  6. java 中 equals和==的区别

    public static void main(String[] args) { int n=0; int m=0; System.out.println(n==m); String str = ne ...

  7. android环境搭建——工欲善其事,必先利其器 2

    前两天鼓捣android, 搭建环境,不想麻烦就用了  adt-bundle-windows-x86-20140702. rar , 起个模拟器哇塞,太爽了. 出去转一圈唠会回来正好启动成功!有个网友 ...

  8. HTML5,添加图片

    <img src="0.jpg" width="100"  height="150" alt="11">

  9. [tp3.2.1]数据模型 - 简单的模型连接

    新建数据库数据库连接功能    1.写conf.php        /* 数据库设置 */        'DB_TYPE'               =>  '',     // 数据库类 ...

  10. web标准

    仔细看看所有的前端招聘要求,几乎所有的都要求对web标准有深刻的理解. web标准,是一系列标准的集合.对前端来说,因为网页是由结构.表现和行为组成.对应的就有结构化标准语言,主要包括XHTML和XM ...