Changed STL in contrast_preserve file
This commit is contained in:
parent
f85a615f3f
commit
3b239561c6
@ -55,7 +55,7 @@ double norm_m(double);
|
|||||||
|
|
||||||
double norm_m(double E)
|
double norm_m(double E)
|
||||||
{
|
{
|
||||||
return sqrt(pow(E,2));
|
return sqroot(power(E,2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost)
|
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;
|
double ans1 = 0.0;
|
||||||
for(unsigned int i =0;i<alf.size();i++)
|
for(unsigned int i =0;i<alf.size();i++)
|
||||||
{
|
{
|
||||||
ans = ((1 + alf[i])/2) * exp((-1.0 * 0.5 * pow(temp[i],2))/pow(sigma,2));
|
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 * pow(temp1[i],2))/pow(sigma,2));
|
ans1 =((1 - alf[i])/2) * exp((-1.0 * 0.5 * power(temp1[i],2))/power(sigma,2));
|
||||||
G_pos.push_back(ans);
|
G_pos.push_back(ans);
|
||||||
G_neg.push_back(ans1);
|
G_neg.push_back(ans1);
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,42 @@ class Decolor
|
|||||||
};
|
};
|
||||||
|
|
||||||
int rounding(double a);
|
int rounding(double a);
|
||||||
|
double power(double term, int p);
|
||||||
|
double sqroot(double m);
|
||||||
|
|
||||||
int rounding(double a)
|
int rounding(double a)
|
||||||
{
|
{
|
||||||
return int(a + 0.5);
|
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;
|
float sigma = .02;
|
||||||
|
|
||||||
double Decolor::energyCalcu(vector <double> &Cg, vector < vector <double> > &polyGrad, vector <double> &wei)
|
double Decolor::energyCalcu(vector <double> &Cg, vector < vector <double> > &polyGrad, vector <double> &wei)
|
||||||
@ -99,7 +129,7 @@ double Decolor::energyCalcu(vector <double> &Cg, vector < vector <double> > &pol
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int i=0;i<polyGrad[0].size();i++)
|
for(unsigned int i=0;i<polyGrad[0].size();i++)
|
||||||
P.push_back(-1.0*log(exp(-1.0*pow(temp[i],2)/sigma) + exp(-1.0*pow(temp1[i],2)/sigma)));
|
P.push_back(-1.0*log(exp(-1.0*power(temp[i],2)/sigma) + exp(-1.0*power(temp1[i],2)/sigma)));
|
||||||
|
|
||||||
double sum = 0.0;
|
double sum = 0.0;
|
||||||
for(unsigned int i=0;i<polyGrad[0].size();i++)
|
for(unsigned int i=0;i<polyGrad[0].size();i++)
|
||||||
@ -205,7 +235,7 @@ void Decolor::colorGrad(Mat img, vector <double> &Cg)
|
|||||||
double res =0.0;
|
double res =0.0;
|
||||||
for(unsigned int i=0;i<ImL.size();i++)
|
for(unsigned int i=0;i<ImL.size();i++)
|
||||||
{
|
{
|
||||||
res=sqrt(pow(ImL[i],2) + pow(Ima[i],2) + pow(Imb[i],2))/100;
|
res=sqroot(power(ImL[i],2) + power(Ima[i],2) + power(Imb[i],2))/100;
|
||||||
Cg.push_back(res);
|
Cg.push_back(res);
|
||||||
}
|
}
|
||||||
lab.release();
|
lab.release();
|
||||||
@ -391,8 +421,8 @@ void Decolor::grad_system(Mat img, vector < vector < double > > &polyGrad,
|
|||||||
for(int i = 0;i<h;i++)
|
for(int i = 0;i<h;i++)
|
||||||
for(int j=0;j<w;j++)
|
for(int j=0;j<w;j++)
|
||||||
curIm.at<float>(i,j)=
|
curIm.at<float>(i,j)=
|
||||||
pow(red.at<float>(i,j),r)*pow(green.at<float>(i,j),g)*
|
power(red.at<float>(i,j),r)*power(green.at<float>(i,j),g)*
|
||||||
pow(blue.at<float>(i,j),b);
|
power(blue.at<float>(i,j),b);
|
||||||
vector <double> curGrad;
|
vector <double> curGrad;
|
||||||
gradvector(curIm,curGrad);
|
gradvector(curIm,curGrad);
|
||||||
add_to_vector_poly(polyGrad,curGrad);
|
add_to_vector_poly(polyGrad,curGrad);
|
||||||
@ -485,8 +515,8 @@ void Decolor::grayImContruct(vector <double> &wei, Mat img, Mat &Gray)
|
|||||||
for(int i = 0;i<h;i++)
|
for(int i = 0;i<h;i++)
|
||||||
for(int j=0;j<w;j++)
|
for(int j=0;j<w;j++)
|
||||||
Gray.at<float>(i,j)=Gray.at<float>(i,j) +
|
Gray.at<float>(i,j)=Gray.at<float>(i,j) +
|
||||||
(float) wei[kk]*pow(red.at<float>(i,j),r)*pow(green.at<float>(i,j),g)*
|
(float) wei[kk]*power(red.at<float>(i,j),r)*power(green.at<float>(i,j),g)*
|
||||||
pow(blue.at<float>(i,j),b);
|
power(blue.at<float>(i,j),b);
|
||||||
|
|
||||||
kk=kk+1;
|
kk=kk+1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user