imread()第二个参数
0:返回3通道
=0:返回灰度图
<0:返回原图
Mat 的API:
( Mat image; )
Mat new_image;
new_image = image.clone()
向下采样:
Mat dstImage;
pyrDown(srcImage, dstImage, Size(srcImage.cols / 2, srcImage.rows / 2));
resize图片缩放:
resize(src, dstimage, Size(src.cols / 6, src.rows / 6),0,0,INTER_LINEAR);
二值化
threshold(dst, dst_up, 84, 255, THRESH_BINARY);
友链:
基本的阈值操作:
http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/imgproc/threshold/threshold.html
createTrackbar自己总结
1.首先要声明全局变量(Mat)和 变量参数(int型)
2.其次申明全局函数 static void xxx(int, void*)
3.然后在int mian里操作
实例:
namedWindow(“Demo”, CV_WINDOW_AUTOSIZE);
//创建显示窗口
createTrackbar(“Threshold”,”Demo”, &threshold_value,255, Threshold_Demo);
//创建滑动条来控制阈值
Threshold_Demo(0, 0);
//结果在回调函数中显示
4.在全局给出void xxx(int, void)的定义
实例:
void Threshold_Demo(int, void)
{
threshold(dst, dst_up, threshold_value, 255, THRESH_BINARY);
imshow("Demo", dst_up);
}
title: 常用语法笔记
date: 2018-03-28 16:48:30