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

前端 未结 4 2026
走了就别回头了
走了就别回头了 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:06

    Alright, I got to work using mixChannels():I have attached an addition to the code snippet above:

    Mat gr( image.rows, image.cols, CV_8UC3);
    
    // forming an array of matrices is a quite efficient operation,
    // because the matrix data is not copied, only the headers
       Mat out[] = {gr};
    // bgr[1] -> gr[1],
    // bgr[2] -> gr[2], 
    int from_to[] = {1,1, 2,2 };
    mixChannels( &image, 1, out, 2, from_to, 2 );
    
    imshow("R+G",gr);
    

    Thanks Harsha

提交回复
热议问题