Opencv— — mix channels
2016-02-24 11:23
441 查看
// 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
// The program will mix the color channels. #include "PS_Algorithm.h" int main() { string Image_name("4.jpg"); Mat Image=imread(Image_name.c_str()); Mat Image_test(Image.size(),CV_32FC3); Image.convertTo(Image_test, CV_32FC3); Mat New_img(Image_test.size(), CV_32FC3); Mat r, g, b; Mat bgr[]={b,g,r}; split(Image_test, bgr); b=bgr[0]; g=bgr[1]; r=bgr[2]; float blueGreen, redBlue, greenRed; blueGreen=0.5; redBlue=0.5; greenRed=0.5; float intoR, intoG, intoB; intoR=0.75; intoG=0.25, intoB=0.75; Mat N_R(r.size(), CV_32FC1); Mat N_G(r.size(), CV_32FC1); Mat N_B(r.size(), CV_32FC1); Mat new_bgr[]={N_B, N_G, N_R}; N_R=(intoR * (blueGreen*g+(1-blueGreen)*b) + (1-intoR)*r); N_G=(intoG * (redBlue*b+(1-redBlue)*r) + (1-intoG)*g); N_B=(intoB * (greenRed*r+(1-greenRed)*g) + (1-intoB)*b); merge(new_bgr, 3, New_img); New_img=New_img/255.0; Show_Image(New_img, "New_img"); cout<<"All is well."<<endl; 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/46790129
相关文章推荐
- NGINX 配置404错误页面转向
- 【转载】运维小技巧:使用ss命令代替 netstat
- 国内几个重要的B2C网站
- docker swarm
- tomcat7-maven-plugin部署项目到远程tomcat报错
- CentOS6.4 LVS+keepalived高可用负载均衡服务配置
- nginx php5 整合
- 修改linux主机名导致mysql启动失败
- 在Windows和Linux上安装paramiko模块以及easy_install的安装方法
- [转] Linux中文件查找技术(名称、…
- discuz centos linux 部署标准
- nginx安装及配置
- Xcode6中如何修改文件中自动创建的Created by和Copyright 文件模板
- linux history 删除
- Tomcat无法启动A child container failed during start
- linux笔记_磁盘分区
- linux shell的here document用法(cat << EOF)
- 很强的nginx rewrite研究(强烈推荐…
- LNMP一键安装包redhat,centos
- nginx 全局变量