Commit 89e78605 authored by Adrien BAK's avatar Adrien BAK

replace double by float

parent ed9f6a3c
...@@ -56,7 +56,7 @@ namespace cv ...@@ -56,7 +56,7 @@ namespace cv
void normal_clone(const cv::Mat& destination, const cv::Mat &mask, const cv::Mat &wmask, cv::Mat &cloned, int flag); void normal_clone(const cv::Mat& destination, const cv::Mat &mask, const cv::Mat &wmask, cv::Mat &cloned, int flag);
void illum_change(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float alpha, float beta); void illum_change(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float alpha, float beta);
void local_color_change(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float red_mul, float green_mul, float blue_mul); void local_color_change(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float red_mul, float green_mul, float blue_mul);
void texture_flatten(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, double low_threshold, double high_threhold, int kernel_size, cv::Mat &cloned); void texture_flatten(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, float low_threshold, float high_threhold, int kernel_size, cv::Mat &cloned);
protected: protected:
...@@ -65,10 +65,10 @@ namespace cv ...@@ -65,10 +65,10 @@ namespace cv
void scalar_product(cv::Mat mat, float r, float g, float b); void scalar_product(cv::Mat mat, float r, float g, float b);
void poisson(const cv::Mat &destination); void poisson(const cv::Mat &destination);
void evaluate(const cv::Mat &I, const cv::Mat &wmask, const cv::Mat &cloned); void evaluate(const cv::Mat &I, const cv::Mat &wmask, const cv::Mat &cloned);
void dst(const std::vector<double>& mod_diff, std::vector<double>& sineTransform,int h,int w); void dst(const std::vector<float>& mod_diff, std::vector<float>& sineTransform,int h,int w);
void idst(const std::vector<double>& mod_diff, std::vector<double>& sineTransform,int h,int w); void idst(const std::vector<float>& mod_diff, std::vector<float>& sineTransform,int h,int w);
void transpose(const std::vector<double>& mat, std::vector<double>& mat_t,int h,int w); void transpose(const std::vector<float>& mat, std::vector<float>& mat_t,int h,int w);
void solve(const cv::Mat &img, const std::vector<double>& mod_diff, cv::Mat &result); void solve(const cv::Mat &img, const std::vector<float>& mod_diff, cv::Mat &result);
void poisson_solver(const cv::Mat &img, cv::Mat &gxx , cv::Mat &gyy, cv::Mat &result); void poisson_solver(const cv::Mat &img, cv::Mat &gxx , cv::Mat &gyy, cv::Mat &result);
void array_product(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& result) const; void array_product(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& result) const;
......
...@@ -81,7 +81,7 @@ void Cloning::computeLaplacianY( const Mat &img, Mat &laplacianY) ...@@ -81,7 +81,7 @@ void Cloning::computeLaplacianY( const Mat &img, Mat &laplacianY)
filter2D(img, laplacianY, CV_32F, kernel); filter2D(img, laplacianY, CV_32F, kernel);
} }
void Cloning::dst(const std::vector<double>& mod_diff, std::vector<double>& sineTransform,int h,int w) void Cloning::dst(const std::vector<float>& mod_diff, std::vector<float>& sineTransform,int h,int w)
{ {
unsigned long int idx; unsigned long int idx;
...@@ -94,7 +94,7 @@ void Cloning::dst(const std::vector<double>& mod_diff, std::vector<double>& sine ...@@ -94,7 +94,7 @@ void Cloning::dst(const std::vector<double>& mod_diff, std::vector<double>& sine
Mat result; Mat result;
int p=0; int p=0;
const double factor = 0.5; const float factor = 0.5;
for(int i=0;i<w;i++) for(int i=0;i<w;i++)
{ {
...@@ -136,7 +136,7 @@ void Cloning::dst(const std::vector<double>& mod_diff, std::vector<double>& sine ...@@ -136,7 +136,7 @@ void Cloning::dst(const std::vector<double>& mod_diff, std::vector<double>& sine
} }
} }
void Cloning::idst(const std::vector<double>& mod_diff, std::vector<double>& sineTransform,int h,int w) void Cloning::idst(const std::vector<float>& mod_diff, std::vector<float>& sineTransform,int h,int w)
{ {
int nn = h+1; int nn = h+1;
unsigned long int idx; unsigned long int idx;
...@@ -145,12 +145,12 @@ void Cloning::idst(const std::vector<double>& mod_diff, std::vector<double>& sin ...@@ -145,12 +145,12 @@ void Cloning::idst(const std::vector<double>& mod_diff, std::vector<double>& sin
for(int j=0;j<w;j++) for(int j=0;j<w;j++)
{ {
idx = i*w + j; idx = i*w + j;
sineTransform[idx] = (double) (2*sineTransform[idx])/nn; sineTransform[idx] = (float) (2*sineTransform[idx])/nn;
} }
} }
void Cloning::transpose(const std::vector<double>& mat, std::vector<double>& mat_t,int h,int w) void Cloning::transpose(const std::vector<float>& mat, std::vector<float>& mat_t,int h,int w)
{ {
Mat tmp = Mat(h,w,CV_32FC1); Mat tmp = Mat(h,w,CV_32FC1);
...@@ -174,16 +174,16 @@ void Cloning::transpose(const std::vector<double>& mat, std::vector<double>& mat ...@@ -174,16 +174,16 @@ void Cloning::transpose(const std::vector<double>& mat, std::vector<double>& mat
} }
} }
void Cloning::solve(const Mat &img, const std::vector<double>& mod_diff, Mat &result) void Cloning::solve(const Mat &img, const std::vector<float>& mod_diff, Mat &result)
{ {
const int w = img.size().width; const int w = img.size().width;
const int h = img.size().height; const int h = img.size().height;
std::vector<double> sineTransform((h-2)*(w-2), 0.); std::vector<float> sineTransform((h-2)*(w-2), 0.);
std::vector<double> sineTranformTranspose((h-2)*(w-2), 0.); std::vector<float> sineTranformTranspose((h-2)*(w-2), 0.);
std::vector<double> denom((h-2)*(w-2), 0.); std::vector<float> denom((h-2)*(w-2), 0.);
std::vector<double> invsineTransform((h-2)*(w-2), 0.); std::vector<float> invsineTransform((h-2)*(w-2), 0.);
std::vector<double> invsineTransform_t((h-2)*(w-2), 0.); std::vector<float> invsineTransform_t((h-2)*(w-2), 0.);
dst(mod_diff,sineTransform,h-2,w-2); dst(mod_diff,sineTransform,h-2,w-2);
...@@ -231,7 +231,7 @@ void Cloning::solve(const Mat &img, const std::vector<double>& mod_diff, Mat &re ...@@ -231,7 +231,7 @@ void Cloning::solve(const Mat &img, const std::vector<double>& mod_diff, Mat &re
int idx = (j-1)* (w-2) + (i-1); int idx = (j-1)* (w-2) + (i-1);
//saturate cast is not used here, because it behaves differently from the previous implementation //saturate cast is not used here, because it behaves differently from the previous implementation
//most notable, saturate_cast rounds before truncating, here it's the opposite. //most notable, saturate_cast rounds before truncating, here it's the opposite.
double value = invsineTransform_t[idx]; float value = invsineTransform_t[idx];
if(value < 0.) if(value < 0.)
result.ptr<unsigned char>(j)[i] = 0; result.ptr<unsigned char>(j)[i] = 0;
else if (value > 255.0) else if (value > 255.0)
...@@ -267,7 +267,7 @@ void Cloning::poisson_solver(const Mat &img, Mat &laplacianX , Mat &laplacianY, ...@@ -267,7 +267,7 @@ void Cloning::poisson_solver(const Mat &img, Mat &laplacianX , Mat &laplacianY,
rectangle(bound, Point(1, 1), Point(img.cols-2, img.rows-2), Scalar::all(0), -1); rectangle(bound, Point(1, 1), Point(img.cols-2, img.rows-2), Scalar::all(0), -1);
std::vector<double> boundary_point(h*w, 0.); std::vector<float> boundary_point(h*w, 0.);
for(int i =1;i<h-1;i++) for(int i =1;i<h-1;i++)
for(int j=1;j<w-1;j++) for(int j=1;j<w-1;j++)
...@@ -287,7 +287,7 @@ void Cloning::poisson_solver(const Mat &img, Mat &laplacianX , Mat &laplacianY, ...@@ -287,7 +287,7 @@ void Cloning::poisson_solver(const Mat &img, Mat &laplacianX , Mat &laplacianY,
} }
} }
std::vector<double> mod_diff((h-2)*(w-2), 0.); std::vector<float> mod_diff((h-2)*(w-2), 0.);
for(int i = 0 ; i < h-2;i++) for(int i = 0 ; i < h-2;i++)
{ {
for(int j = 0 ; j < w-2; j++) for(int j = 0 ; j < w-2; j++)
...@@ -501,8 +501,8 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alp ...@@ -501,8 +501,8 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alp
evaluate(I,wmask,cloned); evaluate(I,wmask,cloned);
} }
void Cloning::texture_flatten(Mat &I, Mat &mask, Mat &wmask, double low_threshold, void Cloning::texture_flatten(Mat &I, Mat &mask, Mat &wmask, float low_threshold,
double high_threshold, int kernel_size, Mat &cloned) float high_threshold, int kernel_size, Mat &cloned)
{ {
compute_derivatives(I,mask,wmask); compute_derivatives(I,mask,wmask);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment