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

 

#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. 编写一个程序,求s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)的值

    编写一个程序,求s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)的值 1 #import <Foundation/Foundation.h>  2   3 int main( ...

  2. osg绘制一个球体

    //By smells2 at Lab 2012-02-21#include <osg/Group>#include <osg/Geode>#include <osg/S ...

  3. C 替换字符方法--1

    #include "stdafx.h" //linux 底下要去掉这一行 #include <stdio.h> #include<stdlib.h> #in ...

  4. Swift - 语言指南,来自github学习

    @SwiftLanguage 更新于 2016-6-6,更新内容详见 Issue 55.往期更新回顾详见<收录周报> 这份指南汇集了 Swift 语言主流学习资源,并以开发者的视角整理编排 ...

  5. C语言的OOP实践(OOC)

    OOC 面向对象 C 语言编程实践 - 文章 - 伯乐在线http://blog.jobbole.com/105105/ ---硬着头皮看完了,但是感觉还是抽象有不理解的地方,感觉用C实现OOP好难啊 ...

  6. Delphi开发中各种文件扩展名代表什么文件

    暂时就遇到了以下这几种,以后遇到再进行补充 .DPR Delphi Project文件,打开这个文件,就会打开所有的编程的代码文件.包含了Pascal代码 .PAS Pascal文件,Pascal单元 ...

  7. Sexagenary Cycle(天干地支法表示农历年份)

    Sexagenary Cycle Time Limit: 2 Seconds      Memory Limit: 65536 KB 题目链接:zoj 4669 The Chinese sexagen ...

  8. ytu 1064: 输入三个字符串,按由小到大的顺序输出(水题,字符串处理)

    1064: 输入三个字符串,按由小到大的顺序输出 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 471  Solved: 188[Submit][Sta ...

  9. 玩玩Excel下的Power View

    作为微软平台下的数据展示工具,Power View是一个不错的选择.而在Excel 2013下,即使你没有SharePoint的实例那么你也可以玩转它.此篇讲对Excel 2013下的Power Vi ...

  10. TortoiseSVN常用批处理命令 分类: C# 2014-08-09 11:31 648人阅读 评论(1) 收藏

    TortoiseSVN作为源代码管理软件,估计用过的都会说好,在Windows下,配合批处理命令,往往可以事半功倍,整理了下常用的批处理命令: (将下面的内容修改后,保存为*.bat文件执行即可) : ...