其他分享
首页 > 其他分享> > opencv入门学习7

opencv入门学习7

作者:互联网

滚动条操作演示——参数传递度

  1. 设置亮度响应滑动条的回调函数
static void on_lightness(int b, void* userdata) {
	Mat srcImg = *((Mat*)userdata);//将指针解除
	Mat dst = Mat::zeros(srcImg.size(), srcImg.type());
	Mat m = Mat::zeros(srcImg.size(), srcImg.type());
	addWeighted(srcImg, 1.0, m, 0, b, dst);//a*b+c*d+e
	imshow("亮度与对比度调整", dst); 
}
  1. 设置对比度响应滑动条的回调函数
static void on_contrast(int b, void* userdata) {
	Mat srcImg = *((Mat*)userdata);
	Mat dst = Mat::zeros(srcImg.size(), srcImg.type());
	Mat m = Mat::zeros(srcImg.size(), srcImg.type());
	double contrast = b / 200.0;
	addWeighted(srcImg, contrast, m, 0.0, 0, dst);
	imshow("亮度与对比度调整", dst);
}

3.设置Trcakbar函数

createTrackbar("Value Bar:", "亮度与对比度调整", &lightness, max_valus, on_lightness, (void*)(&srcImg));
	createTrackbar("Contrast Bar:", "亮度与对比度调整", &contrast_value, 200, on_contrast, (void*)(&srcImg));
on_lightness(50, &srcImg);

标签:srcImg,Mat,dst,学习,opencv,对比度,void,contrast,入门
来源: https://blog.csdn.net/Wishapp/article/details/120259976