opencv学习10-08图像叠加, 改变亮度和对比度, 在mat上画图像

 

1 addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst)

dst=α⋅src1+β⋅src2+γ

注意src1与src2大小要一致.

2 利用LUT函数实现Gamma correction, 调节对比度和亮度,gamma方法是一种非线性的调节方法:

 

O=pow( (I / 255),  gamma) * 255 

Mat lookUpTable(1, 256, CV_8U);

uchar* p = lookUpTable.ptr();

for( int i = 0; i < 256; ++i)

      p[i] = saturate_cast<uchar>(pow(i / 255.0, gamma_) * 255.0);

Mat res = img.clone();

LUT(img, lookUpTable, res);

3 画直线cv::line(Point start, Point end, Mat img, Scalar color, int thickness, int lineType)

which does the following:

  • Draw a line from Point start to Point end
  • The line is displayed in the image img
  • The line color is defined by Scalar( 0, 0, 0) which is the RGB value correspondent to Black
  • The line thickness is set to thickness (in this case 2)
  • The line is a 8-connected one (lineType = 8)

版权声明:本文为qq_33179208原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。