Opencv— — mix channels

    // 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

转载于:https://www.cnblogs.com/mtcnn/p/9412530.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值