// define head function
#ifndef PS_ALGORITHM_H_INCLUDED
#define PS_ALGORITHM_H_INCLUDED #include <iostream>
#include <string>
#include "cv.h"
#include "highgui.h"
#include "cxmat.hpp"
#include "cxcore.hpp"
#include "math.h" using namespace std;
using namespace cv; void Show_Image(Mat&, const string &); #endif // PS_ALGORITHM_H_INCLUDED #include "PS_Algorithm.h"
#include <time.h> using namespace std;
using namespace cv; #define pi 3.1415926 int main()
{
string Img_name("4.jpg");
Mat Img;
Img=imread(Img_name); Mat Img_out(Img.size(), CV_8UC3); int width=Img.cols;
int height=Img.rows; float rNW=1.0; float gNW=0.0; float bNW=0.0;
float rNE=1.0; float gNE=1.0; float bNE=0.0;
float rSW=0.0; float gSW=0; float bSW=1.0;
float rSE=0.0; float gSE=1.0; float bSE=0.0; float fx, fy;
float p, q, r, g, b; for (int y=0; y<height; y++)
{
for (int x=0; x<width; x++)
{
fx=(float)(x)/width;
fy=(float)(y)/height; p = rNW + (rNE - rNW) * fx;
q = rSW + (rSE - rSW) * fx;
r = ( p + (q - p) * fy );
r = min(max(r, 0.0f), 1.0f); p = gNW + (gNE - gNW) * fx;
q = gSW + (gSE - gSW) * fx;
g = ( p + (q - p) * fy );
g = min(max(g, 0.0f) ,1.0f); p = bNW + (bNE - bNW) * fx;
q = bSW + (bSE - bSW) * fx;
b = ( p + (q - p) * fy );
b = min(max(b, 0.0f), 1.0f); Img_out.at<Vec3b>(y, x)[0]=b*255.0;
Img_out.at<Vec3b>(y, x)[1]=g*255.0;
Img_out.at<Vec3b>(y, x)[2]=r*255.0; }
} Show_Image(Img_out, "out");
cout<<"All is well"<<endl; // imwrite("Out.jpg", Img_out); waitKey();
} // define the show image
#include "PS_Algorithm.h"
#include <iostream>
#include <string> using namespace std;
using namespace cv; void Show_Image(Mat& Image, const string& str)
{
namedWindow(str.c_str(),CV_WINDOW_AUTOSIZE);
imshow(str.c_str(), Image); }

图像效果可以参考:

http://blog.csdn.net/matrix_space/article/details/46906849

Opencv— — Color Gradient的更多相关文章

  1. 图像处理------颜色梯度变化 (Color Gradient)

    有过UI设计经验的一定对2D图形渲染中的Color Gradient 或多或少有些接触,很多编程 语言也提供了Gradient的接口,但是想知道它是怎么实现的嘛? 本文介绍三种简单的颜色梯度变化算法, ...

  2. Color gradient in Delphi FireMonkey

    Introduction to color gradients in Delphi FireMonkey. Video This video covers the basics of color gr ...

  3. OpenCV——颜色均匀渐变

    参考来源: 利用OpenCV生成关于某点的颜色径向均匀渐变图像 // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_A ...

  4. 基于qml创建最简单的图像处理程序(1)-基于qml创建界面

    <基于qml创建最简单的图像处理程序>系列课程及配套代码基于qml创建最简单的图像处理程序(1)-基于qml创建界面http://www.cnblogs.com/jsxyhelu/p/83 ...

  5. HTML5- Canvas入门(二)

    上篇文章我们了解了canvas的定义.获取和基础的绘图操作,其中的绘图功能我们讲解了线段绘制.上色.描边等方面知识点. 今天我们来讲讲矩形(Rectangle)和多边形的绘制. 矩形的绘制一共有两个口 ...

  6. HTML5- Canvas入门(一)

    周老虎落网的时候,网易跟腾讯都推出了牛逼轰轰的HTML5页面来展示其关系网(网易http://news.163.com/special/data_zyk/  ,腾讯http://news.qq.com ...

  7. Atitit 图像处理知识点体系知识图谱 路线图attilax总结 v4 qcb.xlsx

    Atitit 图像处理知识点体系知识图谱 路线图attilax总结 v4 qcb.xlsx 分类 图像处理知识点体系 v2 qb24.xlsx 分类 分类 理论知识 图像金字塔 常用底层操作 卷积扫描 ...

  8. fillStyle图片填充

    图片自找 <!DOCTYPE HTML> <head> <meta charset = "utf-8"> <title>canvas ...

  9. flot - jQuery 图表插件(jquery.flot)使用

    Flot是纯Javascript实现的基于jQuery的图表插件,主要支持线状图和柱状图的绘制(通过插件也可以支持饼状图). 特别注意Flot使用的是UTC时间,最好修改flot.js去掉所有的UTC ...

随机推荐

  1. 【Todo】各种语言里面的for循环 & loop

    会的语言多了,不同语言的语法就会混淆.整理了一下. Java里面: 普通的for循环之外: 有以下格式: for (int x : intarr) { } JS里面: }; for (x in per ...

  2. 【层次查询】Hierarchical Queries之亲兄弟间的排序(ORDER SIBLINGS BY)

    http://blog.itpub.net/519536/viewspace-624176 有关层次查询之前的文章参考如下. [层次查询]Hierarchical Queries之"树的遍历 ...

  3. Eclipse出现&quot;Running Android Lint has encountered a problem&quot;解决方式

    近期打开Eclipse的时候,总是发生这种一个错误:"Running Android Lint has encountered a problem".截图例如以下: . 可是Ecl ...

  4. vue2.0 + vux 项目搭建

    1.快速搭建项目模板 因为项目使用vux,所以推荐使用vux官网的airyland/vux2 模板,vue-cli工具是vue项目的搭建脚手架 默认为 webpack2 模板,如果你需要使用webpa ...

  5. Visual Studio 12无法调试Silverligh应用程序的问题

    环境: Win7 Ultimate X64 Visual Studio 12 (以下简称 VS12) Internet Explorer 9(以下简称 IE9) Silverlight5_x64 ad ...

  6. Selenium系列之--07 操作远程浏览器

    Selenium远程控制浏览,可以通过如下两种方式实现,本质上都是Selenium Grid a.  客户机启Selenium Standalone Server 作为远程服务,服务端通过调用Remo ...

  7. Android学习笔记(十八)——使用意图筛选器和实现浏览网页(附源代码)

    使用意图筛选器 点击下载源代码 1.创建一个Intents项目,给该项目加入一个新类,命名为MyBrowserActivity.在res/layout目录下新增一个browser.xml: 2.在An ...

  8. Windows 7 &amp; Ubuntu 14.04完美双系统安装及系统引导配置----校园网Mentohust配置

    本文写于完美安装双系统之后,所以图片会不全然.主要目的是总结下注意事项.备用. 一.Win7-64-旗舰版U盘安装 win7-64-旗舰版纯净版下载,下载安装后仅仅有1个驱动人生! 附刻盘工具激活工具 ...

  9. kubernetes的Service Account和secret

    系列目录 Service Account Service Account概念的引入是基于这样的使用场景:运行在pod里的进程需要调用Kubernetes API以及非Kubernetes API的其它 ...

  10. git 下载与Linux源码安装最新版

    win: https://git-for-windows.github.io/ 或 https://git-scm.com/downloads   官网!   源码安装git Git 的工作需要调用  ...