原理公式:
α可以拉开像素之间的差距,所以增强了对比度,β提高整体亮度。
小知识点:
再次参考:https://blog.csdn.net/qq_29540745/article/details/52517269
其中8U类型指代 u_int8_t ,它是平台无关的,在任何平台下,它都代表8位无符号数
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
Mat t1, t2;
int main(int agrc, char** agrv) {
t1 = imread("test1.jpg");
if (!t1.data || !t1.data) {
cout << "WRONG";
return -1;
}
char *c2 = "bitwise";
namedWindow(c2, 0);
t1.copyTo(t2);
double light = 1.5;
int li = 30;
for (int row = 0; row < t1.rows; row++) {
for (int col = 0; col < t1.cols; col++) {
t2.at<Vec3b>(row, col)[0] = saturate_cast<uchar>(light*t1.at<Vec3b>(row, col)[0]+li);
t2.at<Vec3b>(row, col)[1] = saturate_cast<uchar>(light*t1.at<Vec3b>(row, col)[1] + li);
t2.at<Vec3b>(row, col)[2] = saturate_cast<uchar>(light*t1.at<Vec3b>(row, col)[2] + li);
}
}
imshow("t1", t1);
imshow(c2, t2);
waitKey(0);
}