使用emgu cv获取图像的像素

时间:2013-09-14 15:09:35

标签: c++ visual-c++ opencv emgucv

为了获取OpenCV中的像素,我使用以下代码:

for( int y=0; y<image->height; y++ ) {
            uchar* ptr = (uchar*) (image->imageData + y * image->widthStep);
            for( int x=0; x<image->width; x++ ) {
                 byteArray[y*image->widthStep+3*x] =  ptr[3*x];     
                  byteArray[y*image->widthStep+3*x+1] =  ptr[3*x+1];   
                   byteArray[y*image->widthStep+3*x+2] =  ptr[3*x+2]; 

            }
    }

但是我不能在EmguCV中使用这样的代码:

for( int y=0; y<rgb32Image->MIplImage.height; y++ ) {
 unsigned char* ptr = (unsigned char*) (rgb32Image->MIplImage.imageData + y*rgb32Image->MIplImage.widthStep); 
 //error C2678: binary '+' : no operator found which takes a left-hand operand of type 'System::IntPtr' (or there is no acceptable conversion)

             for( int x=0; x<rgb32Image->MIplImage.widthStep; x++ ) {
                b[y*rgb32Image->MIplImage.widthStep+3*x] = ptr[3*x];     
                b[y*rgb32Image->MIplImage.widthStep+3*x+1] = ptr[3*x+1];  
                b[y*rgb32Image->MIplImage.widthStep+3*x+2] = ptr[3*x+2]; 

                }

        }

我应该使用什么MIplImage.imageData来获取Emgu CV中图像的像素?

谢谢!

1 个答案:

答案 0 :(得分:0)

您使用的是什么版本的Emgu?我通常使用Emgu的Image类

你可以从中得到一个字节[]     Image.Bytes

此处的文档: http://www.emgu.com/wiki/files/2.0.0.0/html/24efb2ef-4b77-68e5-c8cf-1395430b3666.htm

相关问题