带滚动条的线性混合示例:

 

#include
"stdafx.h"

#include<iostream>

#include<thread>

#include<vector>

#include
<opencv2/core/core.hpp>

#include
<opencv2/contrib/contrib.hpp>

#include
<opencv2/highgui/highgui.hpp>

#include
<opencv2/imgproc/imgproc.hpp>

#include
<opencv2/objdetect/objdetect.hpp>

 

using
namespace cv;

using
namespace std;

 

int g_slider_position = 0;

double alpha = 0.5;

double beta;

Mat src1, src2, dst;

 

void onTrackingbarSlide(int
pos)

{

    alpha = (double)pos / 100;

    beta = (1.0 - alpha);

    addWeighted(src1, alpha, src2, beta, 0.0, dst);

    imshow("Linear Blend", dst);

}

 

int
_tmain(int
argc, _TCHAR* argv[])

{

    double input;

 

    /// Ask the user enter alpha

    std::cout << " Simple Linear Blender " << std::endl;

    std::cout << "-----------------------" << std::endl;

    std::cout << "* Enter alpha [0-1]: ";

    std::cin >> input;

 

    /// We use the alpha provided by the user iff it is between 0 and 1

    if (alpha >= 0 && alpha <= 1)

    {

        alpha = input;

    }

 

    /// Read image ( same size, same type )

    src1 = imread("E:\\myImage\\sql.png");

    src2 = imread("E:\\myImage\\network26.png");

 

    if (!src1.data) { printf("Error loading src1 \n"); return -1; }

    if (!src2.data) { printf("Error loading src2 \n"); return -1; }

 

    /// Create Windows

    namedWindow("Linear Blend", 1);

 

    cvCreateTrackbar("Linear Blend", "Linear Blend", &g_slider_position, 100, onTrackingbarSlide);

 

    beta = (1.0 - alpha);

    addWeighted(src1, alpha, src2, beta, 0.5, dst);

 

    imshow("Linear Blend", dst);

 

    waitKey(0);

    return 0;

}

 

 

原文:http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/core/adding_images/adding_images.html#adding-images

OpenCV 线性混合(4)的更多相关文章

  1. opencv 图像的线性混合

    1 线性混合理论 g(x) = (1-α)*f1(x) + α*f2(x) 其中,α代表图像的权重 #include<iostream> #include<opencv2/openc ...

  2. 线性混合+ROI

    相关代码: #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namesp ...

  3. R语言︱线性混合模型理论与案例探究(固定效应&随机效应)

    每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- 线性混合模型与普通的线性模型不同的地方是除了有 ...

  4. OpenCV——ROI截取、线性混合、通道分离、合并、亮度对比度调整

    #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace st ...

  5. opencv基于混合高斯模型的图像分割

    #include "stdafx.h" #include <opencv\cv.h> #include <opencv\highgui.h> #includ ...

  6. CUDA跟OpenCV的混合编程,注意OpenCV需要重新编译

    1.注意事项 编译的办法参见: http://blog.csdn.net/wangyaninglm/article/details/39997113   以下是程序代码,网上搜的例子: 注意事项:32 ...

  7. opencv: 线性拟合

    opencv提供了fitline函数用于直线拟合,原型为: C++: void fitLine(InputArray points, OutputArray line, int distType, d ...

  8. opencv学习笔记-图像叠加、混合

    在图像处理中,目标区域定义为感兴趣区域ROI(region of Interest),这是后期图像处理的基础,在获取ROI后,进行一些列的处理.ROI区域在Opencv中就是Rect,先构建Rect, ...

  9. 跟我一起学opencv 第五课之图像的混合

    *理论-线性混合操作 g(x) = (1-α)f0(x)+αf1(x)  α的取值范围位0-1之间  f0(x)为图像1,f1(x)表示第二张图像 α是混合系数   g(x)是生成的图像,对每一个像素 ...

随机推荐

  1. linux service命令常见使用方法

    service命令,顾名思义,就是用于管理Linux操作系统中服务的命令. 1. 声明:这个命令不是在所有的linux发行版本中都有.主要是在redhat.fedora.mandriva和centos ...

  2. Android错误:Re-installation failed due to different application signatures

    Re-installation failed due to different application signatures (2013-04-20 14:27:32) 转载▼ 标签: 解决方法 问题 ...

  3. Android 毛玻璃效果

    muzei live wallpaper https://github.com/romannurik/muzei

  4. 三、jQuery--jQuery基础--jQuery基础课程--第4章 jQuery表单选择器

    1.:input表单选择器 如何获取表单全部元素?:input表单选择器可以实现,它的功能是返回全部的表单元素,不仅包括所有<input>标记的表单元素,而且还包括<textarea ...

  5. win10总是自动重启的解决办法

    win10总是自动重启的解决办法_百度经验http://jingyan.baidu.com/article/7908e85c983523af481ad214.html

  6. Delphi中线程类TThread实现多线程编程1---构造、析构……

    参考:http://www.cnblogs.com/rogee/archive/2010/09/20/1832053.html Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大 ...

  7. git 常用的简单命令

    git add . 会把当前目录中所有有改动的文件(不包括.gitignore中要忽略的文件)都添加到git缓冲区以待提交 git add * 会把当前目录中所有有改动的文件(包括.gitignore ...

  8. 人人网的账号登录及api操作

    .renren.php <?php /** * PHP Library for renren.com * * @author */ class renrenPHP { function __co ...

  9. Parallel.js初探

    今天闲着看了一下Parallel.js.这个库暂时貌似还没有什么中文的介绍(可能暂时用的人都不多吧).所以就只能上github找它得源码和介绍看看了.貌似它的代码也不多,以后可以深入研究一下. 先简单 ...

  10. hdu 4031 2011成都赛区网络赛A题 线段树 ***

    就是不知道时间该怎么处理,想了好久,看了别人的题解发现原来是暴力,暴力也很巧妙啊,想不出来的那种  -_-! #include<cstdio> #include<iostream&g ...