您的位置:首页 > 运维架构

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

2013-05-13 15:36 656 查看

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: