OpenCV中读取图像像素值

Home / C++ MrLee 2015-5-12 3274

OpenCV中用于读取图像像素点的值的方法很多,这里主要提供了两种常用的方法。
利用IplImage数据类型的imageData定位数据缓冲区来实现,imageData包含指向图像第一个像素数据的指针
例:
	if (pSrcImage != 0) {
		//pSrcImage为IplImage*
		for (int i = 0; i < pSrcImage->height; ++i) {
			uchar * pucPixel = (uchar*) pSrcImage->imageData
				+ i * pSrcImage->widthStep;
			for (int j = 0; j < pSrcImage->width; ++j) {
				pucPixel[3 * j] = 0; //像素第一个通道的值
				pucPixel[3 * j + 1] = 0; //像素第二个通道的值
				pucPixel[3 * j + 2] = 0; //像素第三个通道的值
			}
		}
	}

本文链接:https://www.it72.com/2854.htm

推荐阅读
最新回复 (0)
返回