OpenCV: Taking a 3 channel RGB image, splitting channels and viewing an image with only R+G

前端 未结 4 2025
走了就别回头了
走了就别回头了 2020-12-14 07:26

I wanted to look at only the R+G channels in an RGB image because I get better contrasts to detect an object when the Blue channel is removed. I used OpenCV to split the cha

4条回答
  •  半阙折子戏
    2020-12-14 08:09

    another way is subtracting Scalar(255,0,0) from source image

    #include 
    using namespace cv;
    
    int main(int argc, char **argv)
    {
        Mat src = imread(argv[1], CV_LOAD_IMAGE_COLOR);
        imshow("src", src );
        src -= Scalar(255,0,0);
        imshow("Green and Red channels", src );
        waitKey();
        return 0;
    }
    

提交回复
热议问题