1#include <iostream>
2#include <opencv2/opencv.hpp>
3usingnamespaceStd
4usingnamespaceCv
5//--------------------Declare a global function---------------------------------
6StaticvoidOn_contrastandbright (int,void*);
7//StaticvoidHelphelp ();
8 //--------------------Declare a global variable---------------------------------
9Mat srcimg;
TenMat dstimg;
OneintG_bright;
AintG_contrast;
-//--------------------Main function entry-----------------------------------
-intMain ()
the{
-Srcimg = Imread ("1.jpg");
-if(!srcimg.data)
-{
+cout<<"0000"<<endl;
-}
+dstimg = Mat::zeros (Srcimg.size (), Srcimg.type ());
ANamedwindow ("Stage2",1);
atintG_bright = the;
-intG_contrst = the;
-Namedwindow ("Stage",1);
-//creat the Trackbar
-Createtrackbar ("contrast","Stage2", &g_contrast, -, on_contrastandbright);
-Createtrackbar ("Bright","Stage2", &g_bright, -, on_contrastandbright);
inOn_contrastandbright (G_contrst,0);
-On_contrastandbright (G_bright,0);
to while(Char(Waitkey (1)) !='s')
+{}
-return 0;
the}
*StaticvoidOn_contrastandbright (int,void*)
${
Panax Notoginseng for(intI=0; i<srcimg.rows; i++)
-{
the for(intj=0; j<srcimg.cols; J + +)
+{
A for(intC=0; c<3; C + +)
the{
+Dstimg.at<vec3b> (I,J) [c] = saturate_cast<uchar> ((G_contrast *0.01) * (srcimg.at<vec3b> (I,J) [C]) + g_bright);
-}
$}
$}
-Imshow ("Stage", srcimg);
-Imshow ("Stage2", dstimg);
the}
Contrast adjustment, brightness adjustment.