两个常用的函数是常数的乘法和加法:
- 参数α>0和β通常被称为增益和偏置参数;有时这些参数分别控制对比度和亮度。
-
你可以想到f(x)作为源图像像素和g(x)作为输出图像像素。那么,更方便的是,我们可以将表达式写为:
这里的i,j表示该像素位于第i行第j列。
以下代码执行该操作
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
// we're NOT "using namespace std;" here, to avoid collisions between the beta variable and std::beta in c++17
using std::cin;
using std::cout;
using std::endl;
using namespace cv;
int main( int argc, char** argv )
{
CommandLineParser parser( argc, argv, "{@input | lena.jpg | input image}" );
Mat image = imread( samples::findFile( parser.get<String>( "@input" ) ) );
if( image.empty() )
{
cout << "Could not open or find the image!\n" << endl;
cout << "Usage: " << argv[0] << " <Input image>" << endl;
return -1;
}
Mat new_image = Mat::zeros( image.size(),