Using Mat::at(i,j) in opencv for a 2-D Mat object

后端 未结 3 875
说谎
说谎 2020-12-10 07:39

I am using Ubuntu 12.04 and OpenCV 2

I have written the following code :

IplImage* img =0;
img = cvLoadImage(\"nature.jpg\");
if(img != 0)
{
    Mat         


        
3条回答
  •  生来不讨喜
    2020-12-10 08:11

    Img_mat is a 3 channeled image. Each channel consists of pixel values uchar in data type. So with split(Img_mat, BGR) the Img_mat is split into 3 planes of blue, green and red which are collectively stored in a vector BGR. So BGR[0] is the first (blue) plane with uchar data type pixels...hence it will be

    int dataB = (int)BGR[0].at(i,j);
    int dataG = (int)BGR[1].at(i,j);
    

    so on...

提交回复
热议问题