mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Revert Back
This commit is contained in:
parent
6c7272bde1
commit
94eab9babe
@ -55,7 +55,7 @@ double norm_m(double);
|
||||
|
||||
double norm_m(double E)
|
||||
{
|
||||
return sqrt(power(E,2));
|
||||
return sqrt(pow(E,2));
|
||||
}
|
||||
|
||||
void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost)
|
||||
@ -136,8 +136,8 @@ void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost)
|
||||
double ans1 = 0.0;
|
||||
for(unsigned int i =0;i<alf.size();i++)
|
||||
{
|
||||
ans = ((1 + alf[i])/2) * exp((-1.0 * 0.5 * power(temp[i],2))/power(sigma,2));
|
||||
ans1 =((1 - alf[i])/2) * exp((-1.0 * 0.5 * power(temp1[i],2))/power(sigma,2));
|
||||
ans = ((1 + alf[i])/2) * exp((-1.0 * 0.5 * pow(temp[i],2))/pow(sigma,2));
|
||||
ans1 =((1 - alf[i])/2) * exp((-1.0 * 0.5 * pow(temp1[i],2))/pow(sigma,2));
|
||||
G_pos.push_back(ans);
|
||||
G_neg.push_back(ans1);
|
||||
}
|
||||
|
@ -74,42 +74,12 @@ class Decolor
|
||||
};
|
||||
|
||||
int rounding(double a);
|
||||
double power(double term, int p);
|
||||
double sqroot(double m);
|
||||
|
||||
int rounding(double a)
|
||||
{
|
||||
return int(a + 0.5);
|
||||
}
|
||||
|
||||
double power(double term, int p)
|
||||
{
|
||||
double res = 1.0;
|
||||
for(int i=0;i<p;i++)
|
||||
{
|
||||
res *= term;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
double sqroot(double m)
|
||||
{
|
||||
double i=0;
|
||||
double x1,x2;
|
||||
while( (i*i) <= m )
|
||||
i+=0.1;
|
||||
x1=i;
|
||||
for(int j=0;j<10;j++)
|
||||
{
|
||||
x2=m;
|
||||
x2/=x1;
|
||||
x2+=x1;
|
||||
x2/=2;
|
||||
x1=x2;
|
||||
}
|
||||
return x2;
|
||||
}
|
||||
|
||||
float sigma = .02;
|
||||
|
||||
double Decolor::energyCalcu(vector <double> &Cg, vector < vector <double> > &polyGrad, vector <double> &wei)
|
||||
@ -129,7 +99,7 @@ double Decolor::energyCalcu(vector <double> &Cg, vector < vector <double> > &pol
|
||||
}
|
||||
|
||||
for(unsigned int i=0;i<polyGrad[0].size();i++)
|
||||
P.push_back(-1.0*log(exp(-1.0*power(temp[i],2)/sigma) + exp(-1.0*power(temp1[i],2)/sigma)));
|
||||
P.push_back(-1.0*log(exp(-1.0*pow(temp[i],2)/sigma) + exp(-1.0*pow(temp1[i],2)/sigma)));
|
||||
|
||||
double sum = 0.0;
|
||||
for(unsigned int i=0;i<polyGrad[0].size();i++)
|
||||
@ -235,7 +205,7 @@ void Decolor::colorGrad(Mat img, vector <double> &Cg)
|
||||
double res =0.0;
|
||||
for(unsigned int i=0;i<ImL.size();i++)
|
||||
{
|
||||
res=sqrt(power(ImL[i],2) + power(Ima[i],2) + power(Imb[i],2))/100;
|
||||
res=sqrt(pow(ImL[i],2) + pow(Ima[i],2) + pow(Imb[i],2))/100;
|
||||
Cg.push_back(res);
|
||||
}
|
||||
lab.release();
|
||||
@ -421,8 +391,8 @@ void Decolor::grad_system(Mat img, vector < vector < double > > &polyGrad,
|
||||
for(int i = 0;i<h;i++)
|
||||
for(int j=0;j<w;j++)
|
||||
curIm.at<float>(i,j)=
|
||||
power(red.at<float>(i,j),r)*power(green.at<float>(i,j),g)*
|
||||
power(blue.at<float>(i,j),b);
|
||||
pow(red.at<float>(i,j),r)*pow(green.at<float>(i,j),g)*
|
||||
pow(blue.at<float>(i,j),b);
|
||||
vector <double> curGrad;
|
||||
gradvector(curIm,curGrad);
|
||||
add_to_vector_poly(polyGrad,curGrad);
|
||||
@ -515,8 +485,8 @@ void Decolor::grayImContruct(vector <double> &wei, Mat img, Mat &Gray)
|
||||
for(int i = 0;i<h;i++)
|
||||
for(int j=0;j<w;j++)
|
||||
Gray.at<float>(i,j)=Gray.at<float>(i,j) +
|
||||
(float) wei[kk]*power(red.at<float>(i,j),r)*power(green.at<float>(i,j),g)*
|
||||
power(blue.at<float>(i,j),b);
|
||||
(float) wei[kk]*pow(red.at<float>(i,j),r)*pow(green.at<float>(i,j),g)*
|
||||
pow(blue.at<float>(i,j),b);
|
||||
|
||||
kk=kk+1;
|
||||
}
|
||||
|
@ -75,18 +75,6 @@ class Cloning
|
||||
void texture_flatten(Mat &I, Mat &mask, Mat &wmask, double low_threshold, double high_threhold, int kernel_size, Mat &final);
|
||||
};
|
||||
|
||||
double power(double term, int p);
|
||||
|
||||
double power(double term, int p)
|
||||
{
|
||||
double res = 1.0;
|
||||
for(int i=0;i<p;i++)
|
||||
{
|
||||
res *= term;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void Cloning::getGradientx( const Mat &img, Mat &gx)
|
||||
{
|
||||
int w = img.size().width;
|
||||
@ -740,7 +728,7 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &final, float alph
|
||||
{
|
||||
|
||||
mag.at<float>(i,j*channel+c) =
|
||||
sqrt(power(srx32.at<float>(i,j*channel+c),2) + power(sry32.at<float>(i,j*channel+c),2));
|
||||
sqrt(pow(srx32.at<float>(i,j*channel+c),2) + pow(sry32.at<float>(i,j*channel+c),2));
|
||||
}
|
||||
|
||||
for(int i=0;i < h; i++)
|
||||
@ -750,9 +738,9 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &final, float alph
|
||||
if(srx32.at<float>(i,j*channel+c) != 0)
|
||||
{
|
||||
srx32.at<float>(i,j*channel+c) =
|
||||
power(alpha,beta)*srx32.at<float>(i,j*channel+c)*power(mag.at<float>(i,j*channel+c),-1*beta);
|
||||
pow(alpha,beta)*srx32.at<float>(i,j*channel+c)*pow(mag.at<float>(i,j*channel+c),-1*beta);
|
||||
sry32.at<float>(i,j*channel+c) =
|
||||
power(alpha,beta)*sry32.at<float>(i,j*channel+c)*power(mag.at<float>(i,j*channel+c),-1*beta);
|
||||
pow(alpha,beta)*sry32.at<float>(i,j*channel+c)*pow(mag.at<float>(i,j*channel+c),-1*beta);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user