\* 设置亮度和对比度*\
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
Mat srcimg;
Mat dstimg;
int ContrastValue = 20;//ContrastValue 代表对比度
int BrightValue = 20; //BrightValue 代表亮度
void onchange(int, void*)
{
for (int i = 0; i < srcimg.rows; i++)
{
for (int j = 0; j < srcimg.cols; j++)
{
dstimg.at<Vec3b>(i, j)[0] = saturate_cast<uchar>(ContrastValue*0.01*srcimg.at<Vec3b>(i, j)[0] + BrightValue);
dstimg.at<Vec3b>(i, j)[1] = saturate_cast<uchar>(ContrastValue*0.01*srcimg.at<Vec3b>(i, j)[1] + BrightValue);
dstimg.at<Vec3b>(i, j)[2] = saturate_cast<uchar>(ContrastValue*0.01*srcimg.at<Vec3b>(i, j)[2] + BrightValue);
}
opencv学习记录——(10)图像亮度调整与通道分离
于 2022-09-11 17:39:30 首次发布