# include <opencv2/highgui.hpp>
# include <opencv2/imgproc.hpp>
# include <iostream> using namespace cv;
using namespace std; int main ( )
{ Mat image = imread ( "SrcMF.jpg" ) ; cv:: Mat m_gray; cv:: cvtColor ( image, m_gray, cv:: COLOR_BGR2GRAY) ; float Gamma = log ( 128.0 / 255.0 ) / log ( cv:: mean ( m_gray) [ 0 ] / 255.0 ) ; cv:: Mat lookUpTable = cv:: Mat :: zeros ( cv:: Size ( 1 , 256 ) , CV_8UC1) ; for ( int i = 0 ; i < 256 ; i++ ) lookUpTable. at < uchar> ( 0 , i) = pow ( i / 255.0 , Gamma) * 255.0 ; cv:: LUT ( image, lookUpTable, image) ; imwrite ( path + "\\06.jpg" , image) ; Mat result; cv:: Mat m_lab; cv:: cvtColor ( image, m_lab, cv:: COLOR_BGR2Lab) ; std:: vector< cv:: Mat> split_lab; cv:: split ( m_lab, split_lab) ; cv:: convertScaleAbs ( split_lab[ 1 ] , split_lab[ 1 ] , 128.0 / cv:: mean ( split_lab[ 1 ] ) [ 0 ] , 0.0 ) ; cv:: convertScaleAbs ( split_lab[ 2 ] , split_lab[ 2 ] , 128.0 / cv:: mean ( split_lab[ 2 ] ) [ 0 ] , 0.0 ) ; cv:: merge ( split_lab, result) ; cv:: cvtColor ( result, result, cv:: COLOR_Lab2BGR) ; imwrite ( "08.jpg" , result) ; return 0 ;
}