saturate_cast防止数据溢出函数
for( int x = 0; x < I_YUV.cols; x++ )
{
Uptr[x] = saturate_cast<uchar>((Uptr[x]-128)/2 + 128);
// Method 3. process the second chroma plane using individual element access
uchar& Vxy = planes[2].at<uchar>(y, x);
Vxy = saturate_cast<uchar>((Vxy-128)/2 + 128);
}
fgets函数
从文件结构体指针stream中读取数据,每次读取一行。读取的数据保存在buf指向的字符数组中,每次最多读取bufsize-1个字符(第bufsize个字符赋'\0'),如果文件中的该行,不足bufsize个字符,则读完该行就结束。函数成功将返回buf,失败或读到文件结尾返回NULL。
颜色空间分割
Mat I_YUV;
cvtColor(I, I_YUV, CV_BGR2YCrCb);
vector<Mat> planes; // Use the STL’s vector structure to store multiple Mat objects
split(I_YUV, planes); // split the image into separate color planes (Y U V)
mat转iplimage
Mat I;
IplImage* pI = &I.operator IplImage();
CvMat* mI = &I.operator CvMat();
iplimage转mat
iplimage* img=cvloadimage(“1.jpg”);
Mat img2(img);