#include<opencv2\opencv.hpp>
#include<iostream>
using namespace cv;
int main()
{
Mat src1=imread("aa.jpg");
Mat src2=imread("bb.jpg");
Mat dst,dst1,dst2;
if(src1.empty()||src2.empty())
{
printf("加载失败\n");
return -1;
}
float alpha=1.5;
float beta =30;
dst=Mat::zeros(src1.size(),src1.type());
for(int i=0;i<src1.rows;i++)
{
for(int j=0;j<src1.cols;j++)
{
if(src1.channels()==3)
{
float b=src1.at<Vec3b>(i,j)[0];
float g=src1.at<Vec3b>(i,j)[1];
float r=src1.at<Vec3b>(i,j)[2];
dst.at<Vec3b>(i,j)[0]=saturate_cast<uchar>(b*alpha+beta);
dst.at<Vec3b>(i,j)[1]=saturate_cast<uchar>(g*alpha+beta);
dst.at<Vec3b>(i,j)[2]=saturate_cast<uchar>(r*alpha+beta);
}
else if(src1.channels()==1){
float v=src1.at<uchar>(i,j);
dst.at<uchar>(i,j)=saturate_cast<uchar>(v*alpha+beta);
}
}
}
imshow("dst",dst);
waitKey(0);
return 0;
}