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

 

#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. iOS中UITableView的一些设置

    不可滑动: ? 1 tableView.userInteractionEnabled = NO; 也可以在storyboard中的userInteractionEnable属性设置 显示导向箭头: ? ...

  2. September 7th 2016 Week 37th Wednesday

    Patience is bitter, but its fruit is sweet. 忍耐是痛苦的,但它的果实却是甜蜜的. However, many may give up before they ...

  3. C/C++中调用python文件

    1.将python27安装目录下include.libs文件夹拷贝至Demo程序目录. 2.Demo项目设置包含Python.h.python27.lib); (因为安装python27的时候,pyt ...

  4. string int 转换

    int转stringint n = 0;std::stringstream ss;std::string str;ss<<n;ss>>str;string转intstd::st ...

  5. js获取url方法

    //设置或获取对象指定的文件名或路径.alert(window.location.pathname); //设置或获取整个 URL 为字符串.alert(window.location.href); ...

  6. 设计模式学习之中介者模式(Mediator,行为型模式)(18)

    转载地址:http://www.cnblogs.com/zhili/p/MediatorPattern.html 一.引言 在现实生活中,有很多中介者模式的身影,例如QQ游戏平台,聊天室.QQ群和短信 ...

  7. 在ubuntu上搭建开发环境10---英文版ubuntu安装中文输入法

    之前安装 ubuntu时候选择安装英文版,但是在查资料的时候难免的要输入中文所以自己弄了一下中文输入法的安装 我安装的是fcitx小企鹅输入法 下面介绍一下安装的过程.....   ubuntu默认的 ...

  8. iOS 随记

    UIImage 走缓存 + (UIImage *)imageNamed:(NSString *)name; 不走缓存 + (UIImage *)imageWithContentsOfFile:(NSS ...

  9. MathType 常用快捷键

    MathType 数学公式编辑器是广大理科生电脑上必不可少的软件!然而在大量公式时,不会巧妙使用快捷键真的是心累身累.巧妙使用MathType数学公式编辑器可加快数学符号的录入速度和效率,这将节约大量 ...

  10. 遍历List过程中删除元素的正确做法(转)

    遍历List过程中删除元素的正确做法   public class ListRemoveTest {     3 public static void main(String[] args) { 4 ...