三色通道分离

其一


#include   
#include   
#include   

using namespace cv;
using namespace std;


bool MultiChannelBlending();

int main()
{
    system("color5E");

    if (MultiChannelBlending())
    {
        cout << endl << "嗯。好了,得出了你需要的混合值图像~";
    }

    waitKey(0);
    return 0;
}


bool MultiChannelBlending()
{
    Mat image = imread("kuang1.jpg");
    resize(image, image, Size(image.cols / 7, image.rows / 7), 0, 0, INTER_LINEAR);

    vector sbgr;
    sbgr.resize(3);
    split(image, sbgr);
    vector mbgr(3);
    Mat bk1(image.size(), CV_8UC1, Scalar(0));


    imshow("imageA-huiduR", sbgr[0]);
    //imwrite("imageA-huiduR.jpg", sbgr[0]);
    //显示彩色的分值
    Mat imageA(image.size(), CV_8UC3);
    mbgr[0] = sbgr[0];
    mbgr[1] = bk1;
    mbgr[2] = bk1;
    merge(mbgr, imageA);
    namedWindow("imageA");
    imshow("imageA", imageA);
    //imwrite("imageA.jpg", imageA);


    imshow("imageB-huiduG", sbgr[1]);
    //imwrite("imageB-huiduG.jpg", sbgr[1]);
    //显示彩色的分值
    Mat imageB(image.size(), CV_8UC3);
    mbgr[0] = bk1;
    mbgr[1] = sbgr[1];
    mbgr[2] = bk1;
    merge(mbgr, imageB);
    namedWindow("imageB");
    imshow("imageB", imageB);
    //imwrite("imageB.jpg", imageB);


    imshow("imageC-huiduB", sbgr[2]);
    //imwrite("imageC-huiduB.jpg", sbgr[2]);
    //显示彩色的分值
    Mat imageC(image.size(), CV_8UC3);
    mbgr[0] = bk1;
    mbgr[1] = bk1;
    mbgr[2] = sbgr[2];
    merge(mbgr, imageC);
    namedWindow("imageC");
    imshow("imageC", imageC);
    //imwrite("imageC.jpg", imageC);

    return true;
}

其二


#include   
#include   
#include   

using namespace cv;
using namespace std;


bool MultiChannelBlending();

int main()
{
    system("color5E");

    if (MultiChannelBlending())
    {
        cout << endl << "嗯。好了,得出了你需要的混合值图像~";
    }

    waitKey(0);
    return 0;
}


bool MultiChannelBlending()
{
    Mat image = imread("kuang1.jpg");
    resize(image, image, Size(image.cols / 7, image.rows / 7), 0, 0, INTER_LINEAR);

    vector sbgr;
    sbgr.resize(3);
    split(image, sbgr);
    vector mbgr(3);
    Mat bk1(image.size(), CV_8UC1, Scalar(0));


    imshow("imageA-huiduR", sbgr[0]);
    //imwrite("imageA-huiduR.jpg", sbgr[0]);
    //显示彩色的分值
    Mat imageA(image.size(), CV_8UC3);
    mbgr[0] = sbgr[0];
    mbgr[1] = bk1;
    mbgr[2] = bk1;
    merge(mbgr, imageA);
    namedWindow("imageA");
    imshow("imageA", imageA);
    //imwrite("imageA.jpg", imageA);


    imshow("imageB-huiduG", sbgr[1]);
    //imwrite("imageB-huiduG.jpg", sbgr[1]);
    //显示彩色的分值
    Mat imageB(image.size(), CV_8UC3);
    mbgr[0] = bk1;
    mbgr[1] = sbgr[1];
    mbgr[2] = bk1;
    merge(mbgr, imageB);
    namedWindow("imageB");
    imshow("imageB", imageB);
    //imwrite("imageB.jpg", imageB);


    imshow("imageC-huiduB", sbgr[2]);
    //imwrite("imageC-huiduB.jpg", sbgr[2]);
    //显示彩色的分值
    Mat imageC(image.size(), CV_8UC3);
    mbgr[0] = bk1;
    mbgr[1] = bk1;
    mbgr[2] = sbgr[2];
    merge(mbgr, imageC);
    namedWindow("imageC");
    imshow("imageC", imageC);
    //imwrite("imageC.jpg", imageC);

    return true;
}