Mat Temp_Image=This - & gt; Cv_Image;
Int Width=Temp_Image. Cols;
Int Height=Temp_Image. Rows;
Float HuiDu [256].
Float TongJi [256].
Memset (& amp; HuiDu, 0, 256);
Memset (& amp; TongJi, 0, 256);
//statistical number of each pixel gray levels
For (int H=0; H & lt; Height; H++)
{
Uchar * PTR=Temp_Image. Ptr
For (int W=0; W & lt; Width; W++)
{
Int temp=PTR [W];
HuiDu [temp] + +;
}
}
//number of cumulative statistics each pixel gray levels
For (int c=0; C & lt; 256; C + +)
{
TongJi=HuiDu [c] [c] the Height/Width * * 1.0 f;//the probability of each pixel point
}
//equalization processing
Float Linshi [256].
Int nDstGray [256].
Memset (& amp; Linshi, 0, 256);
Memset (& amp; NDstGray, 0, 256);
For (int a=0; A. & lt; 256; +)
{
If (a==0)
{
Linshi [0]=TongJi [0];
}
The else
{
Linshi [a]=Linshi [a - 1) + TongJi [a];//the cumulative probability of each pixel point
}
NDstGray [a]=(255.0 f * Linshi [a] + 0.5 f);
}
//map
Mat New_Image=Temp_Image;
New_Image. Rows=Height;
New_Image. Cols=Width;
//uchar * PTR=Temp_Image. Ptr
//uchar * N_ptr=New_Image. Ptr
For (int G=0; G & lt; New_Image. Rows; G + +)
{
//uchar * PTR=Temp_Image. Ptr
Uchar * N_ptr=New_Image. Ptr
For (int K=0; K & lt; New_Image. Cols; K++)
{
Int temp=N_ptr [K].
N_ptr [K]=nDstGray (temp);
}
}
Imshow (" ZhiFangTu New_Image);