/***********************************************************************
* OpenCV 2.4.5 example
* By Nero 2014
* 改变图像的对比度和亮度
***********************************************************************/
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
double alpha;
int beta;
//读取原图
Mat image = imread("Lena.jpg");
//创建新图,像素初始化0,与原图有相同大小和类型
Mat new_image = Mat::zeros (image.size(),image.type());
//初始化
cout << " Basic Linear Transforms " << endl;
cout << "-------------------------" << endl;
cout << "* Enter the alpha value [1.0-3.0]: ";
cin >> alpha;
cout << "* Enter the beta value [0-100]: ";
cin >> beta;
//执行运算 new_image(i,j) = alpha*image(i,j) + beta
image.convertTo (new_image,-1,alpha,beta);
//显示原图
imshow("Lena",image);
imshow("New",new_image);
waitKey(0);
return 0;
}
Class03 改变图像对比度和亮度
最新推荐文章于 2022-04-27 09:59:50 发布