07- 提高图像对比度和亮度 : 代码部分
#include<opencv2/opencv.hpp>;
#include<iostream>;
using namespace std;
using namespace cv;
int main(int argc, char* srgv) { //07- 调整图像对比度 和 亮度
Mat source1, change1;
source1 = imread("F:\\OpenCV-Test\\TestPicture\\SourcePicture1\\1.PNG");
if (source1.empty()) {
printf("can not load image ... \n");
return -1;
}
char source1Title[] = "source1title ";
imshow(source1Title, source1);
//cvtColor(source1,change1,6); //灰度图像 nchannels==1;单通道
//contrast and bright changes
change1 = Mat::zeros(source1.size(), source1.type());
//Mat source2;
//source1.convertTo(source2,CV_32F);
//将source1的图像深度转为32位即3b转为3f数据,提取像素值时可用source1.at<Vec3f>(row, col)[0]
int rows = source1.rows;
int cols = source1.cols;
int nchannels = source1.channels();
float alpha = 1.5;
float beta = 30;
for (int row = 0; row < rows; row++)