本帖最后由 hikarutoto 于 2011-06-28 17:19:23 编辑

解决方案 »

  1.   

    OpenCV的图像指针?Iplimage *?
      

  2.   

    灰度图的转换,拷贝一段给你参考。
            IplImage * gray = cvCreateImage(cvSize(nWidth, nHeight), IPL_DEPTH_8U, 1);
    UCHAR * pData = (UCHAR*)malloc(sizeof(UCHAR) * nWidth * nHeight);
    for(int i = 0; i < nHeight; i++){
    for(int j = 0; j < nWidth; j++){
    *(pData + nWidth * (nHeight - 1 - i) + j) = 
    (UCHAR)*(lpDIBBits + nWidth * (nHeight - 1 - i) + j);
    }
    }
    memcpy(gray->imageData, pData, nWidth * nHeight);
      

  3.   

    上面那个罗嗦了一点,
    实际上可以不需要UCHAR * pData = (UCHAR*)malloc(sizeof(UCHAR) * nWidth * nHeight);
    直接把*(pData + nWidth * (nHeight - 1 - i) + j) = 
    (UCHAR)*(lpDIBBits + nWidth * (nHeight - 1 - i) + j);中的pData换成gray->imageData;
      

  4.   


    IplImage*src=workImg;
    double *pix=new double[h*w];
    for(i=0;i<h;i++)
    {
    for(j=0;j<w;j++)
    {
    pixel=(unsigned char*)(src->imageData+i*w+j);
    pix[i*w+j]=*(pixel);
    }
    }
    pix_out[i*w+j]=pix[i*w+j];