1、 Mat
2、imwrite("apple.jpg",frame);
3、imshow("image",frame); 显示图像
4、resize(frame,frame_temp,Size(width,height)); 改变图像大小
5、
6、 创建一幅图像
8、Mat frame; Mat frame_temp; //直接赋值矩阵
9、//深复制,完全复制
Mat b;
Mat a = b;
Mat a = Mat( b,Rect(2,5,15,20) );
10、Mat frame;
或
或
彩色图像:
11、Mat frame; //更改某个像素的值
opencv c++ mat获取像素及像素赋值
灰度图像获取像素值:
for (int i = 0; i < image.cols; i++) { for (int j = 0; j < image.rows; j++) { uchar value = image.at(j,i); } }
彩色图像获取像素分量值:
for (int i = 0; i < image.cols; i++) { for (int j = 0; j < image.rows; j++) { Vec3b intensity = image.at(j, i); for(int k = 0; k < image.channels(); k++) { uchar col = intensity.val[k]; } } }
像素赋值 :
uchar pixValue; for (int i = 0; i < image.cols; i++) { for (int j = 0; j < image.rows; j++) { Vec3b &intensity = image.at(j, i); for(int k = 0; k < image.channels(); k++) { // calculate pixValue intensity.val[k] = pixValue; } } }
12、absdiff( frame, frame_temp, silh_ );
13、threshold( silh_, silh_, 30, 255, CV_THRESH_BINARY );
14、namedWindow("image");//创建图像窗口
15、
16、opencv读取视频:
17、imshow("Tracker", frame);// Display
18、分出YUV三分量;
19、(图像掩码)把一幅图像的一块区域复制到另一幅图像的另一个区域
Mat image_1;
Rect rect_1 = Rect( 3,10,200,100 );
Mat image_2;
Rect rect_2 = Rect( 18,30,200,100 );
image_1(rect_1).copTo( image_2(rect_2) );
20、变换矩阵的行和列