/*--------------------CSS部分-------------------*/ /*--------------------JS部分-------------------*/

opencv学习笔记-入门(7)单通道的图像数据访问

4) 基于指针的直接访问: (简单高效)

  • 对于单通道字节型图像:
    int height     = img->height;
    int width      = img->width;
    int step       = img->widthStep;
    uchar* data    = (uchar *)img->imageData;
    data[i*step+j] = 111;</pre><br><span style="color:rgb(51,153,51)"></span>

     

    对于多通道字节型图像:
  • int height     = img->height;
    int width      = img->width;
    int step       = img->widthStep;
    int channels   = img->nChannels;
    uchar* data    = (uchar *)img->imageData;
    data[i*step+j*channels+k] = 111;</pre><br><span style="color:rgb(51,153,51)"></span>
    
        {
            uchar *sptr = src->data.ptr + src->step*y;
            uchar *pDataOutput = dst->data.ptr + src->step*y;
            for(int x = 0; x < size.width; x++, pDataOutput++, sptr+=Nds)
            {
                for(int iD = 0; iD < Nds; iD++)
                {
                    data[iD] = sqrt(float(sptr[iD]));
            
                }
            }
        }    </pre><br><br>

     



 

posted @ 2013-05-13 15:36  bldong  阅读(591)  评论(0编辑  收藏  举报