程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> Opencv— — mix channels

Opencv— — mix channels

編輯:關於C++
    // define head function
                #ifndef PS_ALGORITHM_H_INCLUDED
                #define PS_ALGORITHM_H_INCLUDED

                #include 
                #include 
                #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."<
// define the show image
        #include "PS_Algorithm.h"
        #include 
        #include 

        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);

        }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved