Windows.Graphics.Capture 截图如何将rgb提取出来


    int i,j;//像素点坐标
    int cPointR,cPointG,cPointB;
    IplImage *img=cvLoadImage("image/color.jpg",1);
    CvScalar s=cvGet2D(img,i,j); //得到像素灰度值
    cPointR=    s.val[0];
    cPointG=    s.val[1];
    cPointB=    s.val[2];

    }

//halcon
HObject Image;
HTuple Grayval;
ReadImage (&Image, 'image/color.jpg');
GetGrayval(Image, i, j, &Grayval);//得到像素灰度值
cPointR=Grayval[0].I();
cPointG=Grayval[1].I();
cPointB=Grayval[2].I();

前面那个写快了,有两处小错误

转成uchar 就可以看到里面的rgb值,当然,直接用opencv或halcon里面的算子更方便,下面是方法

//opencv 
Mat src=imread("image/color.jpg");
    int i,j;//像素点坐标
    int cPointR,cPointG,cPointB;
    IplImage *img=cvLoadImage("image/color.jpg",1);
    CvScalar s=cvGet2D(img,i,j); //得到像素灰度值
    cPointR=    s.val[0];
    cPointG=    s.val[1];
    cPointB=    s.val[2];

    }

//halcon
HObject Image;
HTuple Grayval;
ReadImage (Image, 'image/color.jpg');
GetGrayval(Image, i, j, Grayval);//得到像素灰度值
cPointR=Grayval[0].I();
cPointG=Grayval[1].I();
cPointB=Grayval[2].I();