标签:opencv
对于单通道字节型图像:IplImage* img = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1); int height = img->height; int width = img->width; int step = img->widthStep; uchar* data = (uchar *)img->imageData; //这里注意step不能换成width,数据会4字节对齐,step指每行像素所占字节数 data[i*step+j] = 100;对于多通道字节型图像:
IplImage* img = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,3); 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] = 100;对于多通道浮点型图像(假设图像数据采用4字节(32位)行对齐方式):
IplImage* img = cvCreateImage(cvSize(640,480),IPL_DEPTH_32F,3); int height = img->height; int width = img->width; int step = img->widthStep; int channels = img->nChannels; float * data = (float *)img->imageData; data[i*step+j*channels+k] = 100;
标签:opencv
原文地址:http://blog.csdn.net/lsh_2013/article/details/45039393